Skip to content

Commit

Permalink
Apply reviewed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Candlebury committed Sep 24, 2019
1 parent e90193f commit 6697f8f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
1 change: 0 additions & 1 deletion data/json/legacy_artifact_active.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"flags": [ "NO_HANDS", "SILENT", "NO_LEGS", "UNSAFE_TELEPORT" ],
"min_range": 2,
"max_range": 12,
"max_level": 1,
"message": "You teleport!"
},
{
Expand Down
9 changes: 0 additions & 9 deletions src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@
#include "timed_event.h"
#include "teleport.h"

static tripoint random_point( int min_distance, int max_distance, const tripoint &player_pos )
{
const int angle = rng( 0, 360 );
const int dist = rng( min_distance, max_distance );
const int x = round( dist * cos( angle ) );
const int y = round( dist * sin( angle ) );
return player_pos + point( x, y );
}

void spell_effect::teleport_random( const spell &sp, Creature &caster, const tripoint & )
{
bool safe = !sp.has_flag( spell_flag::UNSAFE_TELEPORT );
Expand Down
22 changes: 11 additions & 11 deletions src/teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

const efftype_id effect_teleglow( "teleglow" );

bool teleport::teleport( Creature *c, int min_distance, int max_distance, bool safe,
bool teleport::teleport( Creature *const critter, int min_distance, int max_distance, bool safe,
bool add_teleglow )
{
if( c == nullptr || min_distance > max_distance ) {
if( critter == nullptr || min_distance > max_distance ) {
debugmsg( "ERROR: Function teleport::teleport called with invalid arguments." );
return false;
}

bool c_is_u = ( c == &g->u );
player *p = dynamic_cast<player *>( c );
bool c_is_u = ( critter == &g->u );
player *const p = critter->as_player();
int tries = 0;
tripoint origin = c->pos();
tripoint origin = critter->pos();
tripoint new_pos = tripoint_zero;
do {
int rangle = rng( 0, 360 );
Expand All @@ -41,11 +41,12 @@ bool teleport::teleport( Creature *c, int min_distance, int max_distance, bool s
}
return false;
} else {
c->apply_damage( nullptr, bp_torso, 9999 );
critter->apply_damage( nullptr, bp_torso, 9999 );
if( c_is_u ) {
g->events().send<event_type::teleports_into_wall>( p->getID(), g->m.obstacle_name( new_pos ) );
add_msg( m_bad, _( "You die after teleporting within a solid" ) );
add_msg( m_bad, _( "You die after teleporting into a solid" ) );
}
critter->check_dead_state();
}
}
//handles telefragging other creatures
Expand All @@ -62,27 +63,26 @@ bool teleport::teleport( Creature *c, int min_distance, int max_distance, bool s
add_msg( m_bad, _( "You exlpode into thousands of fragments." ) );
}
if( p ) {
p->add_msg_player_or_npc( m_bad,
p->add_msg_player_or_npc( m_warning,
_( "You teleport into %s, and they explode into thousands of fragments." ),
_( "<npcname> teleports into %s, and they explode into thousands of fragments." ),
poor_soul->disp_name() );
g->events().send<event_type::telefrags_creature>( p->getID(), poor_soul->get_name() );
} else {
if( g->u.sees( poor_soul->pos() ) ) {
add_msg( m_good, _( "%1$s teleports into %2$s, killing them!" ),
c->disp_name(), poor_soul->disp_name() );
critter->disp_name(), poor_soul->disp_name() );
}
}
poor_soul->apply_damage( nullptr, bp_torso, 9999 ); //Splatter real nice.
poor_soul->check_dead_state();
}
}

c->setpos( new_pos );
critter->setpos( new_pos );
//player and npc exclusive teleporting effects
if( p ) {
if( add_teleglow ) {
add_msg( m_bad, _( "unsafe" ) );
p->add_effect( effect_teleglow, 30_minutes );
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/teleport.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace teleport
/** Teleports a creature to a tile within min_distance and max_distance tiles. Limited to 2D.
*bool safe determines wether the teleported creature can telefrag others/itself.
*/
bool teleport( Creature *c, int min_distance = 2, int max_distance = 12, bool safe = false,
bool teleport( Creature *const critter, int min_distance = 2, int max_distance = 12,
bool safe = false,
bool add_teleglow = true );
}

Expand Down

0 comments on commit 6697f8f

Please sign in to comment.