Skip to content

Commit

Permalink
wip on_hit_effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Jun 18, 2024
1 parent 8fac787 commit 0dfaed8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ammo_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ void ammo_effect::load( const JsonObject &jo, const std::string_view )
JsonObject joe = jo.get_object( "explosion" );
aoe_explosion_data = load_explosion_data( joe );
}
if( jo.has_member( "on_hit_effects" ) ) {
JsonArray json_arr = jo.get_array( "on_hit_effects" );
for( JsonObject joe : json_arr ) {
on_hit_effect new_effect;
optional( joe, was_loaded, "bp_to_hit", new_effect.bp_to_hit, bodypart_str_id::NULL_ID() );
mandatory( joe, was_loaded, "duration", new_effect.duration );
mandatory( joe, was_loaded, "effect", new_effect.effect );
mandatory( joe, was_loaded, "intensity", new_effect.intensity );
on_hit_effects.push_back( new_effect );
}
}
optional( jo, was_loaded, "do_flashbang", do_flashbang, false );
optional( jo, was_loaded, "do_emp_blast", do_emp_blast, false );
optional( jo, was_loaded, "foamcrete_build", foamcrete_build, false );
Expand Down
9 changes: 9 additions & 0 deletions src/ammo_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ template <typename T> class generic_factory;

generic_factory<ammo_effect> &get_all_ammo_effects();

struct on_hit_effect {
bodypart_id bp_to_hit;
efftype_id effect;
int duration;
int intensity;
};

struct ammo_effect {
public:
void load( const JsonObject &jo, std::string_view src );
Expand Down Expand Up @@ -53,6 +60,8 @@ struct ammo_effect {
int trail_intensity_max = 0;
int trail_chance = 100;

std::vector<on_hit_effect> on_hit_effects;

// Used by generic_factory
ammo_effect_str_id id;
std::vector<std::pair<ammo_effect_str_id, mod_id>> src;
Expand Down

0 comments on commit 0dfaed8

Please sign in to comment.