Skip to content

Commit

Permalink
Updates to Probability Travel CBM (cataclysmbnteam#1506)
Browse files Browse the repository at this point in the history
* Updates to Probability Travel CBM

* Finally implement the thing
  • Loading branch information
chaosvolt authored Jun 21, 2022
1 parent 9e517cd commit 81039bc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
7 changes: 2 additions & 5 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,9 @@
"id": "bio_probability_travel",
"type": "bionic",
"name": { "str": "Probability Travel" },
"description": "Increases your body's wavelength, allowing you to quantum tunnel through walls, reappearing on the other side. Power drain in standby is minimal, but each tile tunneled through costs 250 bionic power.",
"description": "Increases your body's wavelength, allowing you to quantum tunnel through walls, reappearing on the other side. Activate and select a direction to use. Tunneling costs 100 bionic power per tile traveled through.",
"occupied_bodyparts": [ [ "torso", 20 ], [ "arm_l", 2 ], [ "arm_r", 2 ], [ "leg_l", 3 ], [ "leg_r", 3 ], [ "foot_l", 1 ], [ "foot_r", 1 ] ],
"flags": [ "BIONIC_TOGGLED" ],
"act_cost": "3 J",
"react_cost": "3 J",
"time": 1
"act_cost": "100 kJ"
},
{
"id": "bio_purifier",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@
"type": "BIONIC_ITEM",
"name": { "str": "Probability Travel CBM" },
"looks_like": "bio_int_enhancer",
"description": "Increases the body's wavelength, allowing the user to quantum tunnel through walls, reappearing on the other side. Power drain in standby is minimal, but each tile tunneled through costs 250 bionic power.",
"description": "Increases the body's wavelength, allowing the user to quantum tunnel through walls, reappearing on the other side. Power drain in standby is relatively low, but each tile tunneled through costs 90 bionic power.",
"price": 1400000,
"difficulty": 11
},
Expand Down
3 changes: 0 additions & 3 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
if( g->walk_move( dest_loc, via_ramp ) ) {
return true;
}
if( g->phasing_move( dest_loc ) ) {
return true;
}
if( veh_closed_door ) {
if( !veh1->handle_potential_theft( dynamic_cast<player &>( you ) ) ) {
return true;
Expand Down
16 changes: 16 additions & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static const bionic_id bio_painkiller( "bio_painkiller" );
static const bionic_id bio_plutdump( "bio_plutdump" );
static const bionic_id bio_power_storage( "bio_power_storage" );
static const bionic_id bio_power_storage_mkII( "bio_power_storage_mkII" );
static const bionic_id bio_probability_travel( "bio_probability_travel" );
static const bionic_id bio_radscrubber( "bio_radscrubber" );
static const bionic_id bio_reactor( "bio_reactor" );
static const bionic_id bio_remote( "bio_remote" );
Expand Down Expand Up @@ -1028,6 +1029,21 @@ bool Character::activate_bionic( int b, bool eff_only )
bio.powered = false;
return false;
}

} else if( bio.id == bio_probability_travel ) {
if( const cata::optional<tripoint> pnt = choose_adjacent( _( "Tunnel in which direction?" ) ) ) {
if( g->m.impassable( *pnt ) ) {
add_msg_activate();
g->phasing_move( *pnt );
} else {
refund_power();
add_msg_if_player( m_info, _( "There's nothing to phase through there." ) );
return false;
}
} else {
refund_power();
return false;
}
} else {
add_msg_activate();
}
Expand Down
36 changes: 19 additions & 17 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9942,11 +9942,6 @@ void game::place_player_overmap( const tripoint_abs_omt &om_dest )

bool game::phasing_move( const tripoint &dest_loc, const bool via_ramp )
{
if( !u.has_active_bionic( bionic_id( "bio_probability_travel" ) ) ||
u.get_power_level() < 250_kJ ) {
return false;
}

if( dest_loc.z != u.posz() && !via_ramp ) {
// No vertical phasing yet
return false;
Expand All @@ -9963,20 +9958,13 @@ bool game::phasing_move( const tripoint &dest_loc, const bool via_ramp )
tunneldist += 1;
//Being dimensionally anchored prevents quantum shenanigans.
if( u.worn_with_flag( "DIMENSIONAL_ANCHOR" ) || u.has_effect_with_flag( "DIMENSIONAL_ANCHOR" ) ) {
u.add_msg_if_player( m_info, _( "You are repelled by the barrier!" ) );
u.mod_power_level( -250_kJ ); //cost of tunneling one tile.
return false;
}
if( tunneldist * 250_kJ >
u.get_power_level() ) { //oops, not enough energy! Tunneling costs 250 bionic power per impassable tile
add_msg( _( "You try to quantum tunnel through the barrier but are reflected! Try again with more energy!" ) );
u.mod_power_level( -250_kJ );
u.add_msg_if_player( m_info,
_( "You try to quantum tunnel through the barrier, but something holds you back!" ) );
return false;
}

if( tunneldist > 24 ) {
add_msg( m_info, _( "It's too dangerous to tunnel that far!" ) );
u.mod_power_level( -250_kJ );
return false;
}

Expand All @@ -9985,14 +9973,28 @@ bool game::phasing_move( const tripoint &dest_loc, const bool via_ramp )
}

if( tunneldist != 0 ) {
if( ( tunneldist - 1 ) * 100_kJ
> //The first 100 was already taken up by the bionic's activation cost.
u.get_power_level() ) { //oops, not enough energy! Tunneling costs 100 bionic power per impassable tile
if( tunneldist * 100_kJ >
u.get_max_power_level() ) {
add_msg( _( "You try to quantum tunnel through the barrier but bounce off! You don't have enough bionic power capacity to travel that far." ) );
} else {
add_msg( _( "You try to quantum tunnel through the barrier but are reflected! You need %i bionic power to travel that thickness of material." ),
( 100 * tunneldist ) );
}
return false;
}

if( u.in_vehicle ) {
m.unboard_vehicle( u.pos() );
}

add_msg( _( "You quantum tunnel through the %d-tile wide barrier!" ), tunneldist );
//tunneling costs 250 bionic power per impassable tile
u.mod_power_level( -( tunneldist * 250_kJ ) );
u.moves -= 100; //tunneling costs 100 moves
//tunneling costs 100 bionic power per impassable tile, but the first 100 was already drained by activation.
u.mod_power_level( -( ( tunneldist - 1 ) * 100_kJ ) );
//tunneling costs 100 moves baseline, 50 per extra tile up to a cap of 500 moves
u.moves -= ( 50 + ( tunneldist * 50 ) );
u.setpos( dest );

if( m.veh_at( u.pos() ).part_with_feature( "BOARDABLE", true ) ) {
Expand Down

0 comments on commit 81039bc

Please sign in to comment.