- Determining Turn Order
- Applying Status Effects
- Adjusting Attributes
- Calculating Damage
- Reflecting Damage: if the character survives
- Poison Effect
- Lifesteal: if the character survives
Understanding Attack Rating and Priority in Combat
Attack Rating
-
Impact of Attack Rating
- The attack rating affects both the chance to hit and the order of attacks.
- A higher attack rating allows you to strike first, potentially dealing lethal damage and avoiding an incoming hit.
-
Priority of Magical Attacks
- Magical attacks always have priority over non-magical ones.
- Monsters that use magic attacks have a 25% chance to land a melee attack instead of using magic.
- If you have a magical attack and your opponent has a high attack rating but uses a melee weapon, you can inflict lethal damage without taking any in return, regardless of their chance to hit.
-
When Both Attacks Are Magical
- If both you and your opponent use magical attacks, the attack rating decides the order of attacks.
-
Reversal of Priority
- This rule also works in reverse, where your opponent’s magical attack would take priority if you’re using a non-magical weapon.
Final Hit Chance
This JavaScript function calculates the chance to hit a defender based on various attributes of the attacker and defender, such as their ratings, levels, and other factors.
export function chanceToHit(
attackersAttackRating: number,
defendersDefenceRating: number,
attackersLevel: number,
defendersLevel: number,
arFactor: number,
defenderBlockRating: number,
) {
attackersAttackRating += (attackersAttackRating * arFactor) / 100;
const x = Math.max(attackersAttackRating, 1);
const y = Math.max(attackersAttackRating + defendersDefenceRating, 1);
const z = attackersLevel;
const k = defendersLevel / 2;
const xy = x / y;
const zk = z / (attackersLevel + k);
const base = 2 * xy * zk;
return Math.max(Math.min(base, 0.95), 0.2) * 100 * (1 - adjustAttrDef(defenderBlockRating) / 100);
}
Here's a breakdown of its components:
- attackersAttackRating: The attack rating of the attacker.
- defendersDefenceRating: The defense rating of the defender.
- attackersLevel: The level of the attacker.
- defendersLevel: The level of the defender.
- arFactor: A percentage modifier applied to the attacker's attack rating.
- defenderBlockRating: The block rating of the defender, which reduces the final chance to hit.
¶ Steps and Calculations
- Adjusting Attack Rating:
attackersAttackRating += (attackersAttackRating * arFactor) / 100;
- The attack rating is increased by a percentage (arFactor).
- Mathematical Safeguards:
- Ensures values don't fall below 1:
const x = Math.max(attackersAttackRating, 1);
const y = Math.max(attackersAttackRating + defendersDefenceRating, 1);
- Key Calculations:
xy
: The normalized ratio of the attacker's attack rating to the combined ratings:
const xy = x / y;
zk
: A level-based adjustment factor:
const zk = z / (attackersLevel + k);
where:
const k = defendersLevel / 2;
base
: The base chance to hit:
const base = 2 * xy * zk;
- Capping the Chance to Hit:
- Ensures the final chance is between 20% and 95%:
Math.max(Math.min(base, 0.95), 0.2);
- Block Adjustment:
- Reduces the chance to hit based on the defender's block rating:
(1 - adjustAttrDef(defenderBlockRating) / 100);
- Final Return Value:
- The function multiplies the result by 100 to express it as a percentage:
return ... * 100;
The function returns the final chance to hit after applying:
- A cap between 20% and 95%.
- A reduction based on the defender's block rating.
Attack Rating Factor
Attack Rating Factor
Formula is :
AttackersAttackRating += attackersAttackRating * arFactor / 100
- Effect of Skills:
- Skills like Onslaught modify the AR Factor by a percentage. For example:
- Onslaught adds 30% to the AR Factor.
- If the base Attack Rating is 100 points, Onslaught increases it to 130 points.
- Chance to Hit Enemies:
- The AR directly impacts your likelihood of successfully hitting a target. A higher AR improves your accuracy.
- What It Does Not Affect:
- The AR Factor does not influence the attack order or the sequence of actions in combat. It is strictly tied to hit probability.
Damage Reflection
Damage Reflection
- Single-Turn Lethal Damage:
- You deal enough damage in one action or turn to bring the enemy’s health to zero , effectively killing them instantly.
- No Reflection Triggered:
- Since the enemy is defeated immediately, they have no opportunity to reflect damage back. Reflective abilities generally require the enemy to be alive at the time of damage application for the effect to activate.
This mechanic can be particularly helpful for high-damage characters or strategies that focus on eliminating enemies quickly. By delivering a lethal hit in one turn, players can bypass the risks associated with enemies that reflect or retaliate. Dawn Box for example .
Life Stolen Per Hit
Life Stolen Per Hit
The mechanics of vampirism work as follows:
- Damage Calculation:
- First, the damage that you and the enemy will inflict is calculated.
- Health Restoration:
- Based on the damage dealt, a portion of it is then used to restore the player’s health.
- Lethal Damage Exception:
- If the player receives lethal damage before the health restoration can occur, the vampirism effect will not work, as the player will already be dead.
This means that vampirism can be effective for sustained survival but may not save the player in cases of fatal hits.
Poison
Poison
The poison mechanic works as follows:
-
Attack Phase:
- An attack (Normal or Magic) is performed, and the damage is calculated based on various factors such as attack power, defense, resistances, etc.
- The resulting damage directly reduces the target’s HP.
-
Poison Damage Trigger:
- After the initial damage, the poison effect kicks in, dealing a secondary damage amount.
- The poison damage is based on the HP left after the attack phase.
- Poison damage is inflicted even if the attacker or target has already died from the initial attack.
- This unique mechanic can cause situations where both combatants die in the same round, potentially leading to a draw.
-
Draw Condition:
- If both the player and the enemy die due to poison (for example, if the poison’s secondary damage is enough to kill one or both after the initial attack), the encounter ends in a draw(win and lose situation).
Magic Find
Magic Find
Minting items is possible when a monster dies. Monsters of different types have a chance for a maximum item drop:
- Common – 1
- Rare – 3
- Boss – 10
/// @notice Apply all corrections to the chance of item drop
/// There are two params to increase chances: amplifier and magicFind
/// There are two params to decrease chances: destroyItems and mintDropChanceNgLevelMultiplier
/// @param info Assume here, that info.mintDropChanceNgLevelMultiplier is in the range [0..1e18]
/// @param di Assume that di <= 100
function _adjustChance(uint32 itemChance, MintItemInfo memory info, uint di) internal pure returns (uint) {
uint chance = uint(itemChance) * Math.min(1e18, info.mintDropChanceNgLevelMultiplier) / 1e18;
chance += chance * info.amplifier / StatLib._MAX_AMPLIFIER;
chance += chance * CalcLib.toUint(info.magicFind) / 100;
chance -= chance * di / 100;
return chance;
}