提交 3a0641e5 编写于 作者: V Venera3 提交者: GitHub

Martial art tech effect custom messages, gate tech effects behind arbitrary...

Martial art tech effect custom messages, gate tech effects behind arbitrary character flags (#54414)
上级 56ae13e7
......@@ -21,8 +21,15 @@
{ "stat": "movecost", "scale": 40 }
],
"tech_effects": [
{ "id": "bleed", "chance": 100, "duration": 2000, "permanent": true, "on_damage": false },
{ "id": "downed", "chance": 50, "duration": 2 }
{
"id": "bleed",
"chance": 100,
"duration": 2000,
"permanent": true,
"on_damage": false,
"message": "You bleed the %s dry!"
},
{ "id": "downed", "chance": 50, "duration": 2, "message": "You bonk the %s real good", "req_flag": "DREAMY" }
]
}
]
......@@ -92,7 +92,9 @@
"chance": 100, // Percent chance to apply the effect on this attack
"permanent": false, // If true the effect won't decay (default false)
"duration": 15, // Duration of the effect in turns
"on_damage": true // If true the effect will only be applied if the attack succeeded in doing damage (default true)
"on_damage": true, // If true the effect will only be applied if the attack succeeded in doing damage (default true)
"req_flag": "ANY", // A single arbitrary character flag (from traits, bionics, effects, or bodyparts) required to apply this effect
"message": "Example" // The message to print if you succesfully apply the effect, %s can be substituted for the target's name
}
]
```
......
......@@ -170,7 +170,8 @@ tech_effect_data load_tech_effect_data( const JsonObject &e )
{
return tech_effect_data( efftype_id( e.get_string( "id" ) ), e.get_int( "duration", 0 ),
e.get_bool( "permanent", false ), e.get_bool( "on_damage", true ),
e.get_int( "chance", 100 ) );
e.get_int( "chance", 100 ), e.get_string( "message", "" ),
json_character_flag( e.get_string( "req_flag", "NULL" ) ) );
}
class tech_effect_reader : public generic_typed_reader<tech_effect_reader>
......
......@@ -108,11 +108,13 @@ struct tech_effect_data {
bool permanent;
bool on_damage;
int chance;
std::string message;
json_character_flag req_flag;
tech_effect_data( const efftype_id &nid, int dur, bool perm, bool ondmg,
int nchance ) :
int nchance, std::string message, json_character_flag req_flag ) :
id( nid ), duration( dur ), permanent( perm ), on_damage( ondmg ),
chance( nchance ) {}
chance( nchance ), message( message ), req_flag( req_flag ) {}
};
class ma_technique
......
......@@ -108,6 +108,7 @@ static const json_character_flag json_flag_CBQ_LEARN_BONUS( "CBQ_LEARN_BONUS" );
static const json_character_flag json_flag_HARDTOHIT( "HARDTOHIT" );
static const json_character_flag json_flag_HYPEROPIC( "HYPEROPIC" );
static const json_character_flag json_flag_NEED_ACTIVE_TO_MELEE( "NEED_ACTIVE_TO_MELEE" );
static const json_character_flag json_flag_NULL( "NULL" );
static const json_character_flag json_flag_UNARMED_BONUS( "UNARMED_BONUS" );
static const limb_score_id limb_score_block( "block" );
......@@ -1792,7 +1793,10 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, d
for( const tech_effect_data &eff : technique.tech_effects ) {
// Add the tech's effects if it rolls the chance and either did damage or ignores it
if( x_in_y( eff.chance, 100 ) && ( di.total_damage() != 0 || !eff.on_damage ) ) {
t.add_effect( eff.id, time_duration::from_turns( eff.duration ), eff.permanent );
if( eff.req_flag == json_flag_NULL || has_flag( eff.req_flag ) ) {
t.add_effect( eff.id, time_duration::from_turns( eff.duration ), eff.permanent );
add_msg_if_player( m_good, _( eff.message ), t.disp_name() );
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册