Skip to content

Commit

Permalink
Merge pull request #44533 from kevingranade/fix-free-counters
Browse files Browse the repository at this point in the history
Fix free counters
  • Loading branch information
ZhilkinSerg authored Oct 2, 2020
2 parents e208a89 + 773f580 commit e49eaa0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 53 deletions.
12 changes: 5 additions & 7 deletions data/json/martialarts_fictional.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@
"melee_allowed": true,
"unarmed_allowed": true,
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand Down Expand Up @@ -416,7 +415,7 @@
"weighting": 2,
"knockback_dist": 1,
"knockback_spread": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 2.0 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 2.0 } ]
},
{
"type": "technique",
Expand All @@ -426,8 +425,7 @@
"skill_requirements": [ { "name": "unarmed", "level": 5 } ],
"unarmed_allowed": true,
"dodge_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand Down Expand Up @@ -529,7 +527,7 @@
"unarmed_allowed": true,
"block_counter": true,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 1.25 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 1.25 } ]
},
{
"type": "technique",
Expand All @@ -541,7 +539,7 @@
"block_counter": true,
"crit_tec": true,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 2.0 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 2.0 } ]
},
{
"type": "technique",
Expand Down
53 changes: 16 additions & 37 deletions data/json/techniques.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
"melee_allowed": true,
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ],
"messages": [ "You counter-attack %s", "<npcname> counter-attacks %s" ]
},
{
Expand Down Expand Up @@ -207,8 +206,7 @@
"crit_ok": true,
"disarms": true,
"down_dur": 1,
"knockback_dist": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"knockback_dist": 1
},
{
"type": "technique",
Expand All @@ -221,8 +219,7 @@
"block_counter": true,
"crit_ok": true,
"down_dur": 1,
"knockback_dist": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"knockback_dist": 1
},
{
"type": "technique",
Expand All @@ -236,8 +233,7 @@
"dodge_counter": true,
"crit_ok": true,
"down_dur": 1,
"knockback_dist": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"knockback_dist": 1
},
{
"type": "technique",
Expand All @@ -252,8 +248,7 @@
"crit_ok": true,
"disarms": true,
"down_dur": 1,
"knockback_dist": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"knockback_dist": 1
},
{
"type": "technique",
Expand Down Expand Up @@ -291,7 +286,7 @@
"knockback_spread": 1,
"stun_dur": 1,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 1.25 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 1.25 } ]
},
{
"type": "technique",
Expand Down Expand Up @@ -346,8 +341,7 @@
"skill_requirements": [ { "name": "melee", "level": 5 } ],
"melee_allowed": true,
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand All @@ -357,8 +351,7 @@
"skill_requirements": [ { "name": "unarmed", "level": 5 } ],
"unarmed_allowed": true,
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand Down Expand Up @@ -501,8 +494,7 @@
"skill_requirements": [ { "name": "unarmed", "level": 2 } ],
"unarmed_allowed": true,
"dodge_counter": true,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"down_dur": 1
},
{
"type": "technique",
Expand Down Expand Up @@ -537,7 +529,6 @@
"block_counter": true,
"down_dur": 1,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 0.5 },
{ "stat": "damage", "type": "cut", "scale": 0.5 },
{ "stat": "damage", "type": "stab", "scale": 0.5 }
Expand All @@ -554,7 +545,6 @@
"dodge_counter": true,
"stun_dur": 1,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 0.5 },
{ "stat": "damage", "type": "cut", "scale": 0.5 },
{ "stat": "damage", "type": "stab", "scale": 0.5 }
Expand Down Expand Up @@ -700,7 +690,6 @@
"crit_ok": true,
"stun_dur": 1,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 1.2 },
{ "stat": "damage", "type": "cut", "scale": 1.2 },
{ "stat": "damage", "type": "stab", "scale": 1.2 }
Expand Down Expand Up @@ -853,8 +842,7 @@
"melee_allowed": true,
"unarmed_weapons_allowed": false,
"dodge_counter": true,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"down_dur": 1
},
{
"type": "technique",
Expand All @@ -864,8 +852,7 @@
"skill_requirements": [ { "name": "unarmed", "level": 5 } ],
"unarmed_allowed": true,
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand Down Expand Up @@ -973,8 +960,7 @@
"melee_allowed": true,
"unarmed_allowed": true,
"crit_ok": true,
"block_counter": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"block_counter": true
},
{
"type": "technique",
Expand Down Expand Up @@ -1020,8 +1006,7 @@
"crit_ok": true,
"dodge_counter": true,
"knockback_dist": 1,
"knockback_spread": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"knockback_spread": 1
},
{
"type": "technique",
Expand All @@ -1033,11 +1018,7 @@
"crit_ok": true,
"dodge_counter": true,
"down_dur": 1,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "cut", "scale": 0 },
{ "stat": "damage", "type": "stab", "scale": 0 }
]
"mult_bonuses": [ { "stat": "damage", "type": "cut", "scale": 0 }, { "stat": "damage", "type": "stab", "scale": 0 } ]
},
{
"type": "technique",
Expand Down Expand Up @@ -1411,7 +1392,6 @@
"crit_ok": true,
"knockback_dist": 1,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 0.5 },
{ "stat": "damage", "type": "cut", "scale": 0.5 },
{ "stat": "damage", "type": "stab", "scale": 0.5 }
Expand Down Expand Up @@ -1537,7 +1517,7 @@
"block_counter": true,
"crit_ok": true,
"down_dur": 1,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 1.2 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 1.2 } ]
},
{
"type": "technique",
Expand Down Expand Up @@ -1637,8 +1617,7 @@
"skill_requirements": [ { "name": "unarmed", "level": 5 } ],
"unarmed_allowed": true,
"dodge_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 } ]
"crit_ok": true
},
{
"type": "technique",
Expand All @@ -1658,7 +1637,7 @@
"unarmed_allowed": true,
"dodge_counter": true,
"crit_ok": true,
"mult_bonuses": [ { "stat": "movecost", "scale": 0.0 }, { "stat": "damage", "type": "bash", "scale": 1.25 } ]
"mult_bonuses": [ { "stat": "damage", "type": "bash", "scale": 1.25 } ]
},
{
"type": "technique",
Expand Down
2 changes: 0 additions & 2 deletions data/mods/MMA/techniques.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
"dodge_counter": true,
"crit_ok": true,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 1.2 },
{ "stat": "damage", "type": "cut", "scale": 1.2 },
{ "stat": "damage", "type": "stab", "scale": 1.2 }
Expand Down Expand Up @@ -282,7 +281,6 @@
"block_counter": true,
"crit_ok": true,
"mult_bonuses": [
{ "stat": "movecost", "scale": 0.0 },
{ "stat": "damage", "type": "bash", "scale": 1.2 },
{ "stat": "damage", "type": "cut", "scale": 1.2 },
{ "stat": "damage", "type": "stab", "scale": 1.2 }
Expand Down
23 changes: 16 additions & 7 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,14 +1221,23 @@ matec_id Character::pick_technique( Creature &t, const item &weap,
continue;
}

// skip dodge counter techniques
if( dodge_counter != tec.dodge_counter ) {
continue;
}
if( tec.block_counter || tec.dodge_counter ) {
// skip dodge counter techniques
if( dodge_counter != tec.dodge_counter ) {
continue;
}
// skip block counter techniques
if( block_counter != tec.block_counter ) {
continue;
}
int move_cost = attack_speed( used_weapon() );
move_cost *= tec.move_cost_multiplier( *this );
move_cost += tec.move_cost_penalty( *this );

// skip block counter techniques
if( block_counter != tec.block_counter ) {
continue;
// Don't counter if it would exhaust moves.
if( get_moves() + get_speed() - move_cost < 0 ) {
continue;
}
}

// if critical then select only from critical tecs
Expand Down

0 comments on commit e49eaa0

Please sign in to comment.