Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ammo_effects can cast spells #74167

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/mods/Aftershock/ammo_effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"type": "ammo_effect",
"aoe": { "field_type": "fd_toxic_foam", "intensity_min": 1, "intensity_max": 4, "chance": 70, "radius": 1 }
},
{
"id": "ELECTRIC_CHAIN",
"type": "ammo_effect",
"spell_data": { "id": "spell_electric_chain" }
},
{
"id": "MULTI_EFFECTS",
"type": "ammo_effect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"subtype": "distribution",
"ammo": 100,
"magazine": 100,
"items": [ [ "afs_electro_anomaly_rifle", 1 ], [ "afs_voltaic_pistol", 90 ] ]
"items": [ [ "afs_electro_anomaly_rifle", 1 ], [ "afs_voltaic_pistol", 90 ], [ "afs_archangel_enr", 9 ] ]
},
{
"id": "afs_any_voltaic_mag",
Expand Down
26 changes: 26 additions & 0 deletions data/mods/Aftershock/items/gun/voltaic.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@
"ammo_effects": [ "ELECTRO_ANOMALY" ],
"flags": [ "NEVER_JAMS", "NON_FOULING", "NEEDS_NO_LUBE" ]
},
{
"id": "afs_archangel_enr",
"type": "GUN",
"copy-from": "laser_rifle",
"name": { "str": "W3310 Archangel ENR" },
"description": "A powerful anti-drone defense weapon, the W3310 Archangel is capable of firing a chain of electrical discharges that can arc between multiple targets. Most effective against groups of lightly armored foes, use within closed spaces is not recommended due to the risk of self-inflicted injury.",
"price": "22 kUSD",
"price_postapoc": "22 kUSD",
"ammo": [ "battery" ],
"ammo_to_fire": 0,
"energy_drain": "75 kJ",
"modes": [ [ "DEFAULT", "Pulse ", 1 ] ],
"ranged_damage": [ { "damage_type": "electric", "amount": 15 } ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
"holster": true,
"max_contains_volume": "20 L",
"max_contains_weight": "20 kg",
"magazine_well": "75 ml",
"item_restriction": [ "afs_voltaic_cartridge" ]
}
],
"ammo_effects": [ "ELECTRIC_CHAIN" ],
"flags": [ "NEVER_JAMS", "NON_FOULING", "NEEDS_NO_LUBE" ]
},
{
"id": "afs_voltaic_pistol",
"type": "GUN",
Expand Down
71 changes: 67 additions & 4 deletions data/mods/Aftershock/spells.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,78 @@
"effect": "effect_on_condition",
"effect_str": "afs_motion_sensor_eoc"
},
{
"id": "spell_electric_chain",
"type": "SPELL",
"name": "Superconductive Arc",
"description": "Your weapon arcs electricity to a nearby target.",
"effect": "attack",
"shape": "line",
"valid_targets": [ "hostile", "ground" ],
"flags": [ "SOMATIC", "NO_LEGS", "RANDOM_TARGET", "NO_EXPLOSION_SFX", "RANDOM_DAMAGE" ],
"min_damage": 15,
"max_damage": 15,
"min_range": 15,
"max_range": 15,
"extra_effects": [ { "id": "spell_electric_chain_2" } ],
"difficulty": 1,
"sound_description": "a crackle",
"damage_type": "electric"
},
{
"id": "spell_electric_chain_2",
"type": "SPELL",
"name": "Superconductive Arc II",
"description": "Your bionic weapon arcs electricity to a nearby target.",
"effect": "attack",
"shape": "blast",
"valid_targets": [ "ally", "hostile", "ground" ],
"flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_CRITTER", "NO_EXPLOSION_SFX", "NO_PROJECTILE" ],
"min_damage": 10,
"max_damage": 15,
"extra_effects": [ { "id": "spell_electric_chain_3" } ],
"min_range": 4,
"max_range": 4,
"min_aoe": 2,
"max_aoe": 2,
"field_id": "fd_electricity",
"min_field_intensity": 1,
"max_field_intensity": 1,
"field_chance": 5,
"damage_type": "electric",
"sound_description": "a crackle"
},
{
"id": "spell_electric_chain_3",
"type": "SPELL",
"name": "Superconductive Arc III",
"description": "Your bionic weapon arcs electricity to a nearby target.",
"effect": "attack",
"shape": "blast",
"valid_targets": [ "ally", "hostile", "ground" ],
"flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_CRITTER", "NO_EXPLOSION_SFX", "NO_PROJECTILE" ],
"min_damage": 10,
"max_damage": 15,
"min_range": 4,
"max_range": 4,
"min_aoe": 2,
"max_aoe": 2,
"field_id": "fd_electricity",
"min_field_intensity": 1,
"max_field_intensity": 1,
"field_chance": 5,
"damage_type": "electric",
"sound_description": "a crackle"
},
{
"id": "bio_blade_electric_arc",
"type": "SPELL",
"name": "Superconductive Arc",
"description": "Your bionic weapon arcs electricity to a nearby target.",
"effect": "attack",
"shape": "blast",
"valid_targets": [ "hostile" ],
"flags": [ "SOMATIC", "NO_LEGS", "RANDOM_TARGET", "RANDOM_DAMAGE" ],
"valid_targets": [ "hostile", "ally", "self" ],
"flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_DAMAGE", "RANDOM_AOE" ],
"max_level": 1,
"min_damage": 5,
"max_damage": 15,
Expand All @@ -213,8 +276,8 @@
"description": "Your bionic weapon arcs electricity to a nearby target.",
"effect": "attack",
"shape": "blast",
"valid_targets": [ "hostile" ],
"flags": [ "SOMATIC", "NO_LEGS", "RANDOM_TARGET", "RANDOM_DAMAGE" ],
"valid_targets": [ "hostile", "ally", "self" ],
"flags": [ "LOUD", "RANDOM_TARGET", "RANDOM_DAMAGE", "RANDOM_AOE" ],
"max_level": 1,
"min_damage": 5,
"max_damage": 15,
Expand Down
2 changes: 2 additions & 0 deletions src/ammo_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void ammo_effect::load( const JsonObject &jo, const std::string_view )
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 );
optional( jo, was_loaded, "spell_data", spell_data );


}

Expand Down
2 changes: 2 additions & 0 deletions src/ammo_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "explosion.h"
#include "field_type.h"
#include "magic.h"
#include "type_id.h"

class JsonObject;
Expand All @@ -23,6 +24,7 @@ struct ammo_effect {
void load( const JsonObject &jo, std::string_view src );
void finalize();
void check() const;
fake_spell spell_data;

field_type_id aoe_field_type = fd_null.id_or( INVALID_FIELD_TYPE_ID );
/** used during JSON loading only */
Expand Down
7 changes: 7 additions & 0 deletions src/projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,17 @@ void apply_ammo_effects( const Creature *source, const tripoint &p,
if( ae.foamcrete_build ) {
foamcrete_build( p );
}
//cast ammo effect spells
const spell ammo_spell = ae.spell_data.get_spell();
if( ammo_spell.is_valid() ) {
ammo_spell.cast_all_effects( *const_cast<Creature *>( source ), p );
ammo_spell.make_sound( p, *const_cast<Creature *>( source ) );
}
}
}
}


int max_aoe_size( const std::set<std::string> &tags )
{
int aoe_size = 0;
Expand Down
Loading