From 8403903a16021b3d360d66755e8e45afeaa2b6a2 Mon Sep 17 00:00:00 2001 From: Hymore246 Date: Fri, 24 May 2019 10:28:14 -0500 Subject: [PATCH] Added three new martial art buff events (#30633) * Added new martial art buff events Adds onmiss, oncrit and onkill buff events. --- data/json/martialarts.json | 35 +++++++++++++++++++++++++++++++++++ src/martialarts.cpp | 33 +++++++++++++++++++++++++++++++++ src/martialarts.h | 9 +++++++++ src/melee.cpp | 11 +++++++++++ src/player.h | 6 ++++++ 5 files changed, 94 insertions(+) diff --git a/data/json/martialarts.json b/data/json/martialarts.json index cf2050609591f..4d9ed0c2ba0a7 100644 --- a/data/json/martialarts.json +++ b/data/json/martialarts.json @@ -874,6 +874,41 @@ ] } ], + "oncrit_buffs": [ + { + "id": "debug_crit_buff", + "name": "Lightning Strike", + "description": "Lightning strikes twice. +Perception electric damage for 3 turns. Stacks 2 times.", + "unarmed_allowed": true, + "min_unarmed": 0, + "buff_duration": 3, + "max_stacks": 2, + "flat_bonuses": [ [ "damage", "electric", "per", 1.0 ] ] + } + ], + "onmiss_buffs": [ + { + "id": "debug_miss_buff", + "name": "Getting Angry", + "description": "When I get my hands on you... +2 bash damage for 2 turns. Stacks 5 times.", + "unarmed_allowed": true, + "min_unarmed": 0, + "buff_duration": 2, + "max_stacks": 5, + "flat_bonuses": [ [ "damage", "bash", 2.0 ] ] + } + ], + "onkill_buffs": [ + { + "id": "debug_kill_buff", + "name": "On Fire", + "description": "YOU ARE ON FIRE! +5 fire damage for 5 turns.", + "unarmed_allowed": true, + "min_unarmed": 0, + "buff_duration": 5, + "flat_bonuses": [ [ "damage", "heat", 5.0 ] ] + } + ], "techniques": [ "tec_debug_slow", "tec_debug_arpen" ] }, { diff --git a/src/martialarts.cpp b/src/martialarts.cpp index f19e5d8cc004d..1575ec4394383 100644 --- a/src/martialarts.cpp +++ b/src/martialarts.cpp @@ -208,6 +208,9 @@ void martialart::load( JsonObject &jo, const std::string & ) optional( jo, was_loaded, "ondodge_buffs", ondodge_buffs, ma_buff_reader{} ); optional( jo, was_loaded, "onblock_buffs", onblock_buffs, ma_buff_reader{} ); optional( jo, was_loaded, "ongethit_buffs", ongethit_buffs, ma_buff_reader{} ); + optional( jo, was_loaded, "onmiss_buffs", onmiss_buffs, ma_buff_reader{} ); + optional( jo, was_loaded, "oncrit_buffs", oncrit_buffs, ma_buff_reader{} ); + optional( jo, was_loaded, "onkill_buffs", onkill_buffs, ma_buff_reader{} ); optional( jo, was_loaded, "techniques", techniques, auto_flags_reader {} ); optional( jo, was_loaded, "weapons", weapons, auto_flags_reader {} ); @@ -633,6 +636,21 @@ void martialart::apply_ongethit_buffs( player &u ) const simultaneous_add( u, ongethit_buffs ); } +void martialart::apply_onmiss_buffs( player &u ) const +{ + simultaneous_add( u, onmiss_buffs ); +} + +void martialart::apply_oncrit_buffs( player &u ) const +{ + simultaneous_add( u, oncrit_buffs ); +} + +void martialart::apply_onkill_buffs( player &u ) const +{ + simultaneous_add( u, onkill_buffs ); +} + bool martialart::has_technique( const player &u, const matec_id &tec_id ) const { for( const auto &elem : techniques ) { @@ -781,6 +799,18 @@ void player::ma_ongethit_effects() { style_selected.obj().apply_ongethit_buffs( *this ); } +void player::ma_onmiss_effects() +{ + style_selected.obj().apply_onmiss_buffs( *this ); +} +void player::ma_oncrit_effects() +{ + style_selected.obj().apply_oncrit_buffs( *this ); +} +void player::ma_onkill_effects() +{ + style_selected.obj().apply_onkill_buffs( *this ); +} template static void accumulate_ma_buff_effects( const C &container, F f ) @@ -1074,7 +1104,10 @@ bool ma_style_callback::key( const input_context &ctxt, const input_event &event buff_desc( _( "Passive" ), ma.static_buffs, true ); buff_desc( _( "Move" ), ma.onmove_buffs ); buff_desc( _( "Hit" ), ma.onhit_buffs ); + buff_desc( _( "Miss" ), ma.onmiss_buffs ); buff_desc( _( "Attack" ), ma.onattack_buffs ); + buff_desc( _( "Crit" ), ma.oncrit_buffs ); + buff_desc( _( "Kill" ), ma.onkill_buffs ); buff_desc( _( "Dodge" ), ma.ondodge_buffs ); buff_desc( _( "Block" ), ma.onblock_buffs ); buff_desc( _( "Get hit" ), ma.ongethit_buffs ); diff --git a/src/martialarts.h b/src/martialarts.h index 9b147406404bd..dc9f1fc90f3d5 100644 --- a/src/martialarts.h +++ b/src/martialarts.h @@ -203,6 +203,12 @@ class martialart void apply_ongethit_buffs( player &u ) const; + void apply_onmiss_buffs( player &u ) const; + + void apply_oncrit_buffs( player &u ) const; + + void apply_onkill_buffs( player &u ) const; + // determines if a technique is valid or not for this style bool has_technique( const player &u, const matec_id &tech ) const; // determines if a weapon is valid for this style @@ -235,6 +241,9 @@ class martialart std::vector ondodge_buffs; std::vector onblock_buffs; std::vector ongethit_buffs; + std::vector onmiss_buffs; + std::vector oncrit_buffs; + std::vector onkill_buffs; }; class ma_style_callback : public uilist_callback diff --git a/src/melee.cpp b/src/melee.cpp index c946a6cc6fa08..7646f05399700 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -431,6 +431,8 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc if( has_miss_recovery_tec( cur_weapon ) ) { move_cost /= 2; } + + ma_onmiss_effects(); // trigger martial arts on-miss effects } else { // Remember if we see the monster at start - it may change const bool seen = g->u.sees( t ); @@ -503,9 +505,18 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc if( !specialmsg.empty() ) { add_msg_if_player( m_neutral, specialmsg ); } + + if( critical_hit ) { + ma_oncrit_effects(); // trigger martial arts on-crit effects + } + } t.check_dead_state(); + + if( t.is_dead_state() ) { + ma_onkill_effects(); // trigger martial arts on-kill effects + } } const int melee = get_skill_level( skill_melee ); diff --git a/src/player.h b/src/player.h index f0a2ec5071556..50fb7a2fa8e13 100644 --- a/src/player.h +++ b/src/player.h @@ -497,6 +497,12 @@ class player : public Character void ma_onblock_effects(); /** Fires all get hit-triggered martial arts events */ void ma_ongethit_effects(); + /** Fires all miss-triggered martial arts events */ + void ma_onmiss_effects(); + /** Fires all crit-triggered martial arts events */ + void ma_oncrit_effects(); + /** Fires all kill-triggered martial arts events */ + void ma_onkill_effects(); /** Returns true if the player has any martial arts buffs attached */ bool has_mabuff( const mabuff_id &buff_id ) const;