Skip to content

Commit

Permalink
Merge branch 'CleverRaven:master' into innawood-Battery
Browse files Browse the repository at this point in the history
  • Loading branch information
Entott authored Jan 10, 2025
2 parents 0d17e4f + 5f3e1f5 commit 310d32f
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 86 deletions.
2 changes: 1 addition & 1 deletion data/json/ammo_effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{
"id": "BOUNCE",
"type": "ammo_effect",
"//": "Inflicts target with `bounced` effect and rebounds to a nearby target without this effect. Hardcoded"
"//": "Projectile with this effect will rebound to a nearby target after hitting the oringinal target. Will not choose targets already hit by this projectile. Hardcoded"
},
{
"id": "BURST",
Expand Down
6 changes: 0 additions & 6 deletions data/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@
"name": [ { "str": "Turret Is Targeted", "//~": "NO_I18N" } ],
"desc": [ { "str": "AI tag used for turret targeting sounds. This is a bug if you have it.", "//~": "NO_I18N" } ]
},
{
"type": "effect_type",
"id": "bounced",
"name": [ { "str": "Bounced", "//~": "NO_I18N" } ],
"desc": [ { "str": "AI tag used for bouncing ammo targeting. This is a bug if you have it.", "//~": "NO_I18N" } ]
},
{
"type": "effect_type",
"id": "npc_value_interaction_timer_short",
Expand Down
2 changes: 2 additions & 0 deletions data/mods/Aftershock/items/armor/military_armor.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"type": "ARMOR",
"name": { "str": "IPAV armor" },
"description": "Multipurpose military armor for the torso and upper arms, intended to protect against a wide variety of ballistic or direct energy attacks. Made from a single piece of ablative carbide that keeps it relatively lightweight and completely disposable.",
"category": "armor",
"price": "5 kUSD 500 USD",
"weight": "7 kg",
"volume": "8 L",
"symbol": "[",
Expand Down
4 changes: 2 additions & 2 deletions data/mods/Aftershock/items/grenades.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"looks_like": "grenade_emp",
"name": "electroshock grenade",
"description": "This is an electronic weapon that will emit a short-ranged electric field. When activated, you'll have five turns before it starts doing so; throwing it before that would be a good idea.",
"price": "350 USD",
"use_action": {
"menu_text": "Pull pin",
"need_wielding": true,
Expand Down Expand Up @@ -138,8 +139,7 @@
"description": "This is a military-grade cryo hand grenade. Once it explodes it spreads exotic highly-radioactive shrapnel. Use this item to pull the pin and light the fuse. You will then have five seconds before it explodes; throwing it would be a good idea.",
"weight": "397 g",
"volume": "250 ml",
"price": "15 USD",
"price_postapoc": "10 USD",
"price": "450 USD",
"to_hit": -1,
"material": [ "steel", "plastic" ],
"symbol": "*",
Expand Down
2 changes: 1 addition & 1 deletion data/mods/MindOverMatter/monsters/bosses.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"monster_message": "The air around %3$s wavers and shapes appear!"
}
],
"flags": [ "MIND_SEEING", "TELEPORT_IMMUNE" ]
"flags": [ "TELEPORT_IMMUNE" ]
}
}
]
4 changes: 2 additions & 2 deletions data/mods/MindOverMatter/powers/teleportation.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,12 @@
"energy_source": "STAMINA",
"base_energy_cost": {
"math": [
"u_effect_intensity('effect_teleport_loci_establishment') > -1 ? 0 : max( ( 3000 - ( u_spell_level('teleport_reactive_displacement') * 100 ) ), 1000 )"
"u_effect_intensity('effect_teleport_loci_establishment') > -1 ? 0 : max( ( 3000 - ( u_spell_level('teleport_loci_establishment') * 100 ) ), 1000 )"
]
},
"base_casting_time": {
"math": [
"u_effect_intensity('effect_teleport_loci_establishment') > -1 ? 10 : max( ( 100 - ( u_spell_level('teleport_reactive_displacement') * 5 ) ), 25 )"
"u_effect_intensity('effect_teleport_loci_establishment') > -1 ? 10 : max( ( 100 - ( u_spell_level('teleport_loci_establishment') * 5 ) ), 25 )"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"s_reststop_1_roof",
"s_reststop_2_roof",
"s_restparking_1",
"s_restparking_2"
"s_restparking_2",
"roadstop",
"roadstop_roof",
"roadstop_a",
"roadstop_a_roof"
]
}
]
42 changes: 42 additions & 0 deletions data/mods/aftershock_exoplanet/price_overrides/grenades.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"id": "smokebomb",
"type": "GENERIC",
"name": { "str": "smoke bomb" },
"copy-from": "smokebomb",
"price": "150 USD",
"price_postapoc": "150 USD"
},
{
"id": "grenade_emp",
"type": "TOOL",
"name": { "str": "EMP grenade" },
"copy-from": "grenade_emp",
"price": "500 USD",
"price_postapoc": "500 USD"
},
{
"id": "grenade",
"type": "TOOL",
"name": { "str": "grenade" },
"copy-from": "grenade",
"price": "350 USD",
"price_postapoc": "350 USD"
},
{
"id": "grenade_inc",
"type": "TOOL",
"name": { "str": "incendiary grenade" },
"copy-from": "grenade_inc",
"price": "450 USD",
"price_postapoc": "450 USD"
},
{
"id": "scrambler",
"type": "TOOL",
"name": { "str": "scrambler grenade" },
"copy-from": "scrambler",
"price": "800 USD",
"price_postapoc": "800 USD"
}
]
10 changes: 6 additions & 4 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,11 @@ static void perform_zone_activity_turn(
void activity_handlers::fertilize_plot_do_turn( player_activity *act, Character *you )
{
itype_id fertilizer;

auto have_fertilizer = [&]() {
return !fertilizer.is_empty() && you->has_amount( fertilizer, 1 );
};

auto check_fertilizer = [&]( bool ask_user = true ) -> void {
if( act->str_values.empty() )
{
Expand All @@ -3584,17 +3589,14 @@ void activity_handlers::fertilize_plot_do_turn( player_activity *act, Character
fertilizer = itype_id( act->str_values[0] );

/* If unspecified, or if we're out of what we used before, ask */
if( ask_user && ( fertilizer.is_empty() || !you->has_charges( fertilizer, 1 ) ) )
if( ask_user && !have_fertilizer() )
{
fertilizer = iexamine::choose_fertilizer( *you, "plant",
false /* Don't confirm action with player */ );
act->str_values[0] = fertilizer.str();
}
};

auto have_fertilizer = [&]() {
return !fertilizer.is_empty() && you->has_charges( fertilizer, 1 );
};

const auto reject_tile = [&]( const tripoint_bub_ms & tile ) {
check_fertilizer();
Expand Down
39 changes: 19 additions & 20 deletions src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ static const ammo_effect_str_id ammo_effect_STREAM_TINY( "STREAM_TINY" );
static const ammo_effect_str_id ammo_effect_TANGLE( "TANGLE" );
static const ammo_effect_str_id ammo_effect_WIDE( "WIDE" );

static const efftype_id effect_bounced( "bounced" );

static const itype_id itype_glass_shard( "glass_shard" );

static const json_character_flag json_flag_HARDTOHIT( "HARDTOHIT" );
Expand Down Expand Up @@ -220,10 +218,10 @@ projectile_attack_aim projectile_attack_roll( const dispersion_sources &dispersi
return aim;
}

dealt_projectile_attack projectile_attack( const projectile &proj_arg,
const tripoint_bub_ms &source, const tripoint_bub_ms &target_arg,
const dispersion_sources &dispersion, Creature *origin, const vehicle *in_veh,
const weakpoint_attack &wp_attack, bool first )
void projectile_attack( dealt_projectile_attack &attack, const projectile &proj_arg,
const tripoint_bub_ms &source, const tripoint_bub_ms &target_arg,
const dispersion_sources &dispersion, Creature *origin, const vehicle *in_veh,
const weakpoint_attack &wp_attack, bool first )
{
const bool do_animation = first && get_option<bool>( "ANIMATION_PROJECTILES" );

Expand Down Expand Up @@ -258,14 +256,16 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg,

// TODO: move to-hit roll back in here

dealt_projectile_attack attack {
proj_arg, nullptr, dealt_damage_instance(), source, aim.missed_by
};
attack.proj = proj_arg;
attack.hit_critter = nullptr;
attack.dealt_dam = dealt_damage_instance();
attack.end_point = source;
attack.missed_by = aim.missed_by;

// No suicidal shots
if( source == target_arg ) {
debugmsg( "Projectile_attack targeted own square." );
return attack;
return;
}

projectile &proj = attack.proj;
Expand Down Expand Up @@ -543,30 +543,29 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg,

// TODO: Move this outside now that we have hit point in return values?
if( proj.proj_effects.count( ammo_effect_BOUNCE ) ) {
// Add effect so the shooter is not targeted itself.
if( origin && !origin->has_effect( effect_bounced ) ) {
origin->add_effect( effect_bounced, 1_turns );
}
Creature *mon_ptr = g->get_creature_if( [&]( const Creature & z ) {
if( &z == origin ) {
return false;
}
// search for creatures in radius 4 around impact site
if( rl_dist( z.pos_bub(), tp ) <= 4 &&
here.sees( z.pos_bub(), tp, -1 ) ) {
// don't hit targets that have already been hit
if( !z.has_effect( effect_bounced ) ) {
return true;
for( auto it : attack.targets_hit ) {
if( &z == it.first ) {
return false;
}
}
return true;
}
return false;
} );
if( mon_ptr ) {
Creature &z = *mon_ptr;
add_msg( _( "The attack bounced to %s!" ), z.get_name() );
z.add_effect( effect_bounced, 1_turns );
projectile_attack( proj, tp, z.pos_bub(), dispersion, origin, in_veh );
projectile_attack( attack, proj, tp, z.pos_bub(), dispersion, origin, in_veh );
sfx::play_variant_sound( "fire_gun", "bio_lightning_tail",
sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos_bub() ) );
}
}

return attack;
}
8 changes: 4 additions & 4 deletions src/ballistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ projectile_attack_aim projectile_attack_roll( const dispersion_sources &dispersi
* dispersion.
* Returns the rolled dispersion of the shot and the actually hit point.
*/
dealt_projectile_attack projectile_attack( const projectile &proj_arg,
const tripoint_bub_ms &source, const tripoint_bub_ms &target_arg,
const dispersion_sources &dispersion, Creature *origin = nullptr, const vehicle *in_veh = nullptr,
const weakpoint_attack &attack = weakpoint_attack(), bool first = true );
void projectile_attack( dealt_projectile_attack &attack, const projectile &proj_arg,
const tripoint_bub_ms &source, const tripoint_bub_ms &target_arg,
const dispersion_sources &dispersion, Creature *origin = nullptr, const vehicle *in_veh = nullptr,
const weakpoint_attack &wp_attack = weakpoint_attack(), bool first = true );

/* Used for selecting which part to target in a projectile attack
* Primarily a template for ease of testing, but can be reused!
Expand Down
4 changes: 2 additions & 2 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,8 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics
proj.range = rl_dist( pr.second, pos_bub() ) - 1;
proj.proj_effects = {{ ammo_effect_NO_ITEM_DAMAGE, ammo_effect_DRAW_AS_LINE, ammo_effect_NO_DAMAGE_SCALING, ammo_effect_JET }};

dealt_projectile_attack dealt = projectile_attack(
proj, pr.second, pos_bub(), dispersion_sources{ 0 }, this );
dealt_projectile_attack dealt;
projectile_attack( dealt, proj, pr.second, pos_bub(), dispersion_sources{ 0 }, this );
here.add_item_or_charges( dealt.end_point, pr.first );
}

Expand Down
19 changes: 7 additions & 12 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ struct mutation_branch;
static const ammo_effect_str_id ammo_effect_APPLY_SAP( "APPLY_SAP" );
static const ammo_effect_str_id ammo_effect_BEANBAG( "BEANBAG" );
static const ammo_effect_str_id ammo_effect_BLINDS_EYES( "BLINDS_EYES" );
static const ammo_effect_str_id ammo_effect_BOUNCE( "BOUNCE" );
static const ammo_effect_str_id ammo_effect_FOAMCRETE( "FOAMCRETE" );
static const ammo_effect_str_id ammo_effect_IGNITE( "IGNITE" );
static const ammo_effect_str_id ammo_effect_INCENDIARY( "INCENDIARY" );
Expand All @@ -101,7 +100,6 @@ static const damage_type_id damage_heat( "heat" );

static const efftype_id effect_all_fours( "all_fours" );
static const efftype_id effect_blind( "blind" );
static const efftype_id effect_bounced( "bounced" );
static const efftype_id effect_downed( "downed" );
static const efftype_id effect_eff_mind_seeing_bonus_10( "eff_mind_seeing_bonus_10" );
static const efftype_id effect_eff_mind_seeing_bonus_20( "eff_mind_seeing_bonus_20" );
Expand Down Expand Up @@ -972,13 +970,6 @@ double Creature::accuracy_projectile_attack( dealt_projectile_attack &attack ) c
return attack.missed_by + std::max( 0.0, std::min( 1.0, dodge_rescaled ) );
}

void projectile::apply_effects_nodamage( Creature &target, Creature *source ) const
{
if( proj_effects.count( ammo_effect_BOUNCE ) ) {
target.add_effect( effect_source( source ), effect_bounced, 1_turns );
}
}

void projectile::apply_effects_damage( Creature &target, Creature *source,
const dealt_damage_instance &dealt_dam, bool critical ) const
{
Expand Down Expand Up @@ -1339,8 +1330,6 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack
return;
}

proj.apply_effects_nodamage( *this, source );

// Create a copy that records whether the attack is a crit.
weakpoint_attack wp_attack_copy = wp_attack;
wp_attack_copy.type = weakpoint_attack::attack_type::PROJECTILE;
Expand Down Expand Up @@ -1376,14 +1365,20 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack

proj.apply_effects_damage( *this, source, dealt_dam, goodhit < accuracy_critical );

int total_dam = dealt_dam.total_damage();

if( print_messages ) {
messaging_projectile_attack( source, hit_selection, dealt_dam.total_damage() );
messaging_projectile_attack( source, hit_selection, total_dam );
}

check_dead_state();
attack.hit_critter = this;
attack.missed_by = goodhit;
attack.headshot = hit_selection.is_headshot;
attack.targets_hit[this].first++;
if( total_dam > 0 ) {
attack.targets_hit[this].second += total_dam;
}
}

dealt_damage_instance Creature::deal_damage( Creature *source, bodypart_id bp,
Expand Down
18 changes: 11 additions & 7 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ static bool sting_shoot( monster *z, Creature *target, damage_instance &dam, flo
proj.impact.add( dam );
proj.proj_effects.insert( ammo_effect_NO_OVERSHOOT );

dealt_projectile_attack atk = projectile_attack( proj, z->pos_bub(), target->pos_bub(),
dispersion_sources{ 500 }, z );
dealt_projectile_attack atk;
projectile_attack( atk, proj, z->pos_bub(), target->pos_bub(),
dispersion_sources{ 500 }, z );
if( atk.dealt_dam.total_damage() > 0 ) {
target->add_msg_if_player( m_bad, _( "The %s shoots a dart into you!" ), z->name() );
// whether this function returns true determines whether it applies a status effect like paralysis or mutation
Expand Down Expand Up @@ -733,8 +734,9 @@ bool mattack::acid( monster *z )
proj.impact.add_damage( damage_acid, 5 );
proj.range = 10;
proj.proj_effects.insert( ammo_effect_NO_OVERSHOOT );
dealt_projectile_attack dealt = projectile_attack( proj, z->pos_bub(), target->pos_bub(),
dispersion_sources{ 5400 }, z );
dealt_projectile_attack dealt;
projectile_attack( dealt, proj, z->pos_bub(), target->pos_bub(),
dispersion_sources{ 5400 }, z );
const tripoint_bub_ms &hitp = tripoint_bub_ms( dealt.end_point );
const Creature *hit_critter = dealt.hit_critter;
if( hit_critter == nullptr && here.hit_with_acid( hitp ) ) {
Expand Down Expand Up @@ -958,8 +960,9 @@ bool mattack::pull_metal_weapon( monster *z )
proj.range = rl_dist( foe->pos_bub(), z->pos_bub() ) - 1;
proj.proj_effects = { { ammo_effect_NO_ITEM_DAMAGE, ammo_effect_DRAW_AS_LINE, ammo_effect_NO_DAMAGE_SCALING, ammo_effect_JET } };

dealt_projectile_attack dealt = projectile_attack( proj, foe->pos_bub(), z->pos_bub(),
dispersion_sources{ 0 }, z );
dealt_projectile_attack dealt;
projectile_attack( dealt, proj, foe->pos_bub(), z->pos_bub(),
dispersion_sources{ 0 }, z );
get_map().add_item( dealt.end_point, pulled_weapon );
target->add_msg_player_or_npc( m_type, _( "The %s is pulled away from your hands!" ),
_( "The %s is pulled away from <npcname>'s hands!" ), pulled_weapon.tname() );
Expand Down Expand Up @@ -1555,7 +1558,8 @@ bool mattack::spit_sap( monster *z )
proj.range = 12;
proj.proj_effects.insert( ammo_effect_APPLY_SAP );
proj.impact.add_damage( damage_acid, rng( 5, 10 ) );
projectile_attack( proj, z->pos_bub(), target->pos_bub(), dispersion_sources{ 150 }, z );
dealt_projectile_attack atk;
projectile_attack( atk, proj, z->pos_bub(), target->pos_bub(), dispersion_sources{ 150 }, z );

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/mondefense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ void mdefense::acidsplash( monster &m, Creature *const source,
prj.proj_effects.insert( ammo_effect_DRAW_AS_LINE );
prj.proj_effects.insert( ammo_effect_NO_DAMAGE_SCALING );
prj.impact.add_damage( damage_acid, rng( 1, 3 ) );
dealt_projectile_attack atk;
for( size_t i = 0; i < num_drops; i++ ) {
const tripoint_bub_ms &target = random_entry( pts );
projectile_attack( prj, m.pos_bub(), target, dispersion_sources{ 1200 }, &m );
projectile_attack( atk, prj, m.pos_bub(), target, dispersion_sources{ 1200 }, &m );
}

if( get_player_view().sees( m.pos_bub() ) ) {
Expand Down
Loading

0 comments on commit 310d32f

Please sign in to comment.