# How is experience for Combat Skills calculated?

**URL:** <https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661>\
**Category:** The Bunker\
**Created:** [December 15, 2017, 8:20pm UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661 "2017-12-15T20:20:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![psyxypher](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/psyxypher/32/11778_2.png) [@psyxypher](https://discourse.cataclysmdda.org/u/psyxypher)\
**Post date:** [December 15, 2017, 8:20pm UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/1 "2017-12-15T20:20:43Z")

</div>

This has always eluded me. How does the game determine how much experience to give for Combat Skills when fighting enemies? When is this experience rewarded? Is it when an enemy is attacked? Killed?

I’m playing a character with both Apex Predator and Faster Learner, and I’m trying to get my unarmed as high as possible. So I’m trying to figure out how to do that best, because unlike my Submachine Gun skill, many enemies say they “can’t increase my Unarmed Level past 12” despite the fact I’m still gaining EXP for the skill.

Can anyone clue me into this mystery?

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [December 16, 2017, 8:17am UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/2 "2017-12-16T08:17:15Z")

</div>

XP calculations are done in [game.cpp](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/game.cpp) and [melee.cpp](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/melee.cpp).

There are following formulas:

- 25% chance to get 1 xp/75% chance to get 0 xp for `skill_melee` per successful smash (via _void game::smash()_)

```auto
        if (u.get_skill_level( skill_melee ) == 0) {
            u.practice( skill_melee, rng(0, 1) * rng(0, 1));
        }

```

- Practice melee `skill_melee`, `skill_bashing`, `skill_cutting`, `skill_stabbing` and `skill_unarmed` proportional to damage dealt (via _static void melee\_train( player &p, int lo, int hi, const item &weap )_)

```auto
static void melee_train( player &p, int lo, int hi, const item &weap ) {
    p.practice( skill_melee, ceil( rng( lo, hi ) / 2.0 ), hi );

    // allocate XP proportional to damage stats
    // Pure unarmed needs a special case because it has 0 weapon damage
    int cut = weap.damage_melee( DT_CUT );
    int stab = weap.damage_melee( DT_STAB );
    int bash = weap.damage_melee( DT_BASH ) + ( weap.is_null() ? 1 : 0 );

    float total = std::max( cut + stab + bash, 1 );
    p.practice( skill_cutting, ceil( cut / total * rng( lo, hi ) ), hi );
    p.practice( skill_stabbing, ceil( stab / total * rng( lo, hi ) ), hi );

    // Unarmed skill scaled bashing damage and so scales with bashing damage
    p.practice( weap.has_flag( "UNARMED_WEAPON" ) ? skill_unarmed : skill_bashing,
                ceil( bash / total * rng( lo, hi ) ), hi );
}

```

- When CQB bionic is not active train `skill_melee` (via _void player::melee\_attack(Creature &t, bool allow\_special, const matec\_id &force\_technique, int hit\_spread)_)

_When `hit_spread` is less than 0:_

```auto
        // Practice melee and relevant weapon skill (if any) except when using CQB bionic
        if( !has_active_bionic( bio_cqb ) ) {
            melee_train( *this, 2, 5, cur_weapon );
        }

```

_When `hit_spread` is more than or equal to 0:_

```auto
            // Practice melee and relevant weapon skill (if any) except when using CQB bionic
            if( !has_active_bionic( bio_cqb ) ) {
                melee_train( *this, 5, 10, cur_weapon );
            }

```

- Gain 0 to 10 xp with equal chance with `skill_unarmed` once per combo (via _void player::perform\_special\_attacks(Creature &t)_)

```auto
            if( !practiced ) {
                // Practice unarmed, at most once per combo
                practiced = true;
                practice( skill_unarmed, rng( 0, 10 ) );
            }

```

---

<div class="post-metadata">

**Author:** ![tarburst98](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/tarburst98/32/1355_2.png) [@tarburst98](https://discourse.cataclysmdda.org/u/tarburst98)\
**Post date:** [December 16, 2017, 8:39am UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/3 "2017-12-16T08:39:30Z")

</div>

okay so why do so many enemies generate a “can’t gain XP” message?

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [December 16, 2017, 10:21pm UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/4 "2017-12-16T22:21:31Z")

</div>

I dunno as I’ve never seen such message.

What’s the exact text?

---

<div class="post-metadata">

**Author:** ![tarburst98](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/tarburst98/32/1355_2.png) [@tarburst98](https://discourse.cataclysmdda.org/u/tarburst98)\
**Post date:** [December 17, 2017, 11:25pm UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/5 "2017-12-17T23:25:39Z")

</div>

“this task is too simple to gain any experience” or there abouts. think it usually happens soonest with something like dodging a zombie child.

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [December 18, 2017, 6:21am UTC](https://discourse.cataclysmdda.org/t/how-is-experience-for-combat-skills-calculated/14661/6 "2017-12-18T06:21:22Z")

</div>

> [@tarburst98](#):
>
> this task is too simple to gain any experience think it usually happens soonest with something like dodging a zombie child.

`dodging` is not a combat skill in game definitions
