Skip to content

Commit

Permalink
Fix spell effect and ranged.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Oct 1, 2020
1 parent 0fa6ad3 commit 96ee202
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
15 changes: 12 additions & 3 deletions data/json/artifact/altered_object_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"valid_targets": [ "ground" ],
"effect": "summon",
"effect_str": "mon_vortex",
"shape": "blast",
"base_casting_time": 100,
"message": "Space twists and deforms around you.",
"min_damage": 1,
Expand All @@ -25,6 +26,7 @@
"valid_targets": [ "ground" ],
"effect": "summon",
"effect_str": "mon_hound_tindalos",
"shape": "blast",
"base_casting_time": 100,
"message": "The world unravels into geometric shapes, and between the chaos you spot a horrid prowling beast.",
"min_damage": 1,
Expand All @@ -41,6 +43,7 @@
"name": "Artifact Force Pull",
"description": "Pull objects.",
"effect": "area_pull",
"shape": "blast",
"valid_targets": [ "self", "ally", "hostile", "ground", "item", "field" ],
"message": "An unnatural implosion sends objects flying.",
"min_range": 15,
Expand All @@ -58,6 +61,7 @@
"valid_targets": [ "self" ],
"effect": "spawn_item",
"effect_str": "artifact_teleportitis_aura",
"shape": "blast",
"base_casting_time": 100,
"min_duration": 4000,
"max_duration": 4000
Expand All @@ -71,6 +75,7 @@
"valid_targets": [ "self" ],
"effect": "spawn_item",
"effect_str": "artifact_slow_aura",
"shape": "blast",
"base_casting_time": 100,
"min_duration": 900,
"max_duration": 900
Expand All @@ -83,6 +88,7 @@
"message": "Stale golden light floods the world, and reality stands still.",
"valid_targets": [ "self" ],
"effect": "mod_moves",
"shape": "blast",
"min_damage": 500,
"max_damage": 500,
"base_casting_time": 100
Expand All @@ -94,8 +100,10 @@
"description": "Grants you the Darkness effect",
"message": "Persistent shadows invade your field of view.",
"valid_targets": [ "self" ],
"effect": "target_attack",
"flags": [ "NO_PROJECTILE" ],
"effect": "attack",
"effect_str": "darkness",
"shape": "blast",
"min_duration": 2400,
"max_duration": 2400
},
Expand All @@ -108,7 +116,8 @@
"min_damage": 0,
"max_damage": 10,
"valid_targets": [ "self" ],
"flags": [ "RANDOM_DAMAGE" ],
"effect": "target_attack"
"flags": [ "RANDOM_DAMAGE", "NO_PROJECTILE" ],
"shape": "blast",
"effect": "attack"
}
]
3 changes: 1 addition & 2 deletions src/magic_spell_effect_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct tripoint;
// spells do not reduce in damage the further away from the epicenter the targets are
// rather they do their full damage in the entire area of effect
std::set<tripoint> calculate_spell_effect_area( const spell &sp, const tripoint &target,
const std::function<std::set<tripoint>( const spell &, const tripoint &, const tripoint &, int, bool )>
&aoe_func, const Creature &caster, bool ignore_walls = false );
const Creature &caster );

#endif // CATA_SRC_MAGIC_SPELL_EFFECT_HELPERS_H
26 changes: 17 additions & 9 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2360,15 +2360,23 @@ bool target_ui::set_cursor_pos( const tripoint &new_pos )
if( mode == TargetMode::Fire ) {
recalc_aim_turning_penalty();
} else if( mode == TargetMode::Spell ) {
const std::string fx = casting->effect();
if( fx == "target_attack" || fx == "projectile_attack" || fx == "ter_transform" ) {
spell_aoe = spell_effect::spell_effect_blast( *casting, src, dst, casting->aoe(), true );
} else if( fx == "cone_attack" ) {
spell_aoe = spell_effect::spell_effect_cone( *casting, src, dst, casting->aoe(), true );
} else if( fx == "line_attack" ) {
spell_aoe = spell_effect::spell_effect_line( *casting, src, dst, casting->aoe(), true );
} else {
spell_aoe.clear();
switch( casting->shape() ) {
case spell_shape::blast:
spell_aoe = spell_effect::spell_effect_blast(
spell_effect::override_parameters( *casting ), src, dst );
break;
case spell_shape::cone:
spell_aoe = spell_effect::spell_effect_cone(
spell_effect::override_parameters( *casting ), src, dst );
break;
case spell_shape::line:
spell_aoe = spell_effect::spell_effect_line(
spell_effect::override_parameters( *casting ), src, dst );
break;
default:
spell_aoe.clear();
debugmsg( "%s does not have valid spell shape", casting->id().str() );
break;
}
} else if( mode == TargetMode::Turrets ) {
update_turrets_in_range();
Expand Down
3 changes: 1 addition & 2 deletions tests/magic_spell_effect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ TEST_CASE( "line_attack", "[magic]" )
SECTION( "aoe=0" ) {
const std::set<tripoint> reference( { tripoint_east * 1, tripoint_east * 2, tripoint_east * 3, tripoint_east * 4, tripoint_east * 5 } );

std::set<tripoint> targets = calculate_spell_effect_area( sp, target,
spell_effect::spell_effect_line, c, true );
std::set<tripoint> targets = calculate_spell_effect_area( sp, target, c );

CHECK( reference == targets );
}
Expand Down

0 comments on commit 96ee202

Please sign in to comment.