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

[pull] master from CleverRaven:master #29

Merged
merged 11 commits into from
May 3, 2019
2 changes: 1 addition & 1 deletion data/json/monster_drops.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
}
]
},
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000 }
{ "item": "cash_card", "charges-min": 0, "charges-max": 50000, "prob": 10 }
]
},
{
Expand Down
12 changes: 12 additions & 0 deletions data/mods/blazemod/blaze_blob_recipes.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@
[ [ "mutagen", 3 ], [ "iv_mutagen", 1 ] ]
]
},
{
"result": "frostie_wheel",
"type": "recipe",
"category": "CC_OTHER",
"subcategory": "CSC_OTHER_MATERIALS",
"skill_used": "cooking",
"difficulty": 8,
"time": 15000,
"reversible": true,
"autolearn": true,
"components": [ [ [ "frostie", 1 ] ], [ [ "water", 200 ] ] ]
},
{
"result": "fuzzlegrow",
"type": "recipe",
Expand Down
7 changes: 7 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,13 @@
"id": "control_vehicle",
"bindings": [ { "input_method": "keyboard", "key": "^" } ]
},
{
"type": "keybinding",
"name": "Toggle Auto Travel Mode",
"category": "DEFAULTMODE",
"id": "auto_travel_mode",
"bindings": [ { "input_method": "keyboard", "key": "" } ]
},
{
"type": "keybinding",
"name": "Toggle Safe Mode",
Expand Down
27 changes: 27 additions & 0 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ std::string action_ident( action_id act )
return "sleep";
case ACTION_CONTROL_VEHICLE:
return "control_vehicle";
case ACTION_TOGGLE_AUTO_TRAVEL_MODE:
return "auto_travel_mode";
case ACTION_TOGGLE_SAFEMODE:
return "safemode";
case ACTION_TOGGLE_AUTOSAFE:
Expand Down Expand Up @@ -494,6 +496,30 @@ action_id get_movement_direction_from_delta( const int dx, const int dy, const i
}
}

point get_delta_from_movement_direction( action_id act )
{
switch( act ) {
case ACTION_MOVE_N:
return point_north;
case ACTION_MOVE_NE:
return point_north_east;
case ACTION_MOVE_E:
return point_east;
case ACTION_MOVE_SE:
return point_south_east;
case ACTION_MOVE_S:
return point_south;
case ACTION_MOVE_SW:
return point_south_west;
case ACTION_MOVE_W:
return point_west;
case ACTION_MOVE_NW:
return point_north_west;
default:
return point_zero;
}
}

// Get the key for an action, used in the action menu to give each action the
// hotkey it is bound to.
// We ignore bindings to '?' because that will already do something else in
Expand Down Expand Up @@ -799,6 +825,7 @@ action_id handle_action_menu()
REGISTER_ACTION( ACTION_THROW );
REGISTER_ACTION( ACTION_FIRE_BURST );
REGISTER_ACTION( ACTION_PICK_STYLE );
REGISTER_ACTION( ACTION_TOGGLE_AUTO_TRAVEL_MODE );
REGISTER_ACTION( ACTION_TOGGLE_SAFEMODE );
REGISTER_ACTION( ACTION_TOGGLE_AUTOSAFE );
REGISTER_ACTION( ACTION_IGNORE_ENEMY );
Expand Down
8 changes: 7 additions & 1 deletion src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ template<typename T>
class optional;
} // namespace cata
struct tripoint;
struct point;

/**
* Enumerates all discrete actions that can be performed by player
Expand Down Expand Up @@ -198,6 +199,8 @@ enum action_id : int {
ACTION_SLEEP,
/** Open vehicle control menu */
ACTION_CONTROL_VEHICLE,
/** Turn auto travel mode on/off */
ACTION_TOGGLE_AUTO_TRAVEL_MODE,
/** Turn safemode on/off, while leaving autosafemode intact */
ACTION_TOGGLE_SAFEMODE,
/** Turn automatic triggering of safemode on/off */
Expand Down Expand Up @@ -490,7 +493,7 @@ std::string press_x( action_id act, const std::string &key_bound_pre,
// ('Z'ing|zing) (X( or Y)))
std::string press_x( action_id act, const std::string &act_desc );

// Helper function to convert co-ordinate delta to a movement direction
// Helper function to convert coordinate delta to a movement direction
/**
* Translate coordinate delta into movement direction
*
Expand All @@ -513,6 +516,9 @@ std::string press_x( action_id act, const std::string &act_desc );
*/
action_id get_movement_direction_from_delta( const int dx, const int dy, const int dz = 0 );

// Helper function to convert movement direction to coordinate delta point
point get_delta_from_movement_direction( action_id act );

/**
* Show the action menu
*
Expand Down
9 changes: 9 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ static constexpr point point_min{ tripoint_min.x, tripoint_min.y };
static constexpr point point_zero{ tripoint_zero.x, tripoint_zero.y };
static constexpr point point_max{ tripoint_max.x, tripoint_max.y };

static constexpr point point_north{ 0, -1 };
static constexpr point point_north_east{ 1, -1 };
static constexpr point point_east{ 1, 0 };
static constexpr point point_south_east{ 1, 1 };
static constexpr point point_south{ 0, 1 };
static constexpr point point_south_west{ -1, 1 };
static constexpr point point_west{ -1, 0 };
static constexpr point point_north_west{ -1, -1 };

static constexpr box box_zero( tripoint_zero, tripoint_zero );
static constexpr rectangle rectangle_zero( point_zero, point_zero );

Expand Down
1 change: 1 addition & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,7 @@ input_context get_default_mode_input_context()
ctxt.register_action( "disassemble" );
ctxt.register_action( "sleep" );
ctxt.register_action( "control_vehicle" );
ctxt.register_action( "auto_travel_mode" );
ctxt.register_action( "safemode" );
ctxt.register_action( "autosafe" );
ctxt.register_action( "autoattack" );
Expand Down
7 changes: 7 additions & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ class game
// Standard movement; handles attacks, traps, &c. Returns false if auto move
// should be canceled
bool plmove( int dx, int dy, int dz = 0 );
inline bool plmove( tripoint d ) {
return plmove( d.x, d.y, d.z );
}
inline bool plmove( point d ) {
return plmove( d.x, d.y );
}
// Handle pushing during move, returns true if it handled the move
bool grabbed_move( const tripoint &dp );
bool grabbed_veh_move( const tripoint &dp );
Expand Down Expand Up @@ -1103,6 +1109,7 @@ class game

//pixel minimap management
int pixel_minimap_option;
bool auto_travel_mode = false;
safe_mode_type safe_mode;
int turnssincelastmon; // needed for auto run mode
cata::optional<int> wind_direction_override;
Expand Down
127 changes: 48 additions & 79 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,11 @@ static void rcdrive( int dx, int dy )
}
}

inline static void rcdrive( point d )
{
return rcdrive( d.x, d.y );
}

static void pldrive( int x, int y )
{
if( !g->check_safe_mode_allowed() ) {
Expand Down Expand Up @@ -415,6 +420,11 @@ static void pldrive( int x, int y )
veh->pldrive( x, y );
}

inline static void pldrive( point d )
{
return pldrive( d.x, d.y );
}

static void open()
{
player &u = g->u;
Expand Down Expand Up @@ -1438,6 +1448,7 @@ bool game::handle_action()

// actions allowed only while alive
if( !u.is_dead_state() ) {
point dest_delta;
switch( act ) {
case ACTION_NULL:
case NUM_ACTIONS:
Expand Down Expand Up @@ -1479,93 +1490,15 @@ bool game::handle_action()
break;

case ACTION_MOVE_N:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( 0, -1 );
} else if( veh_ctrl ) {
pldrive( 0, -1 );
} else {
continue_auto_move = plmove( 0, -1 );
}
break;

case ACTION_MOVE_NE:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( 1, -1 );
} else if( veh_ctrl ) {
pldrive( 1, -1 );
} else {
continue_auto_move = plmove( 1, -1 );
}
break;

case ACTION_MOVE_E:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( 1, 0 );
} else if( veh_ctrl ) {
pldrive( 1, 0 );
} else {
continue_auto_move = plmove( 1, 0 );
}
break;

case ACTION_MOVE_SE:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( 1, 1 );
} else if( veh_ctrl ) {
pldrive( 1, 1 );
} else {
continue_auto_move = plmove( 1, 1 );
}
break;

case ACTION_MOVE_S:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( 0, 1 );
} else if( veh_ctrl ) {
pldrive( 0, 1 );
} else {
continue_auto_move = plmove( 0, 1 );
}
break;

case ACTION_MOVE_SW:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( -1, 1 );
} else if( veh_ctrl ) {
pldrive( -1, 1 );
} else {
continue_auto_move = plmove( -1, 1 );
}
break;

case ACTION_MOVE_W:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( -1, 0 );
} else if( veh_ctrl ) {
pldrive( -1, 0 );
} else {
continue_auto_move = plmove( -1, 0 );
}
break;

case ACTION_MOVE_NW:
if( !( u.get_value( "remote_controlling" ).empty() ) && ( ( u.has_active_item( "radiocontrol" ) ) ||
( u.has_active_bionic( bio_remote ) ) ) ) {
rcdrive( -1, -1 );
} else if( veh_ctrl ) {
pldrive( -1, -1 );
} else {
continue_auto_move = plmove( -1, -1 );
}
dest_delta = get_delta_from_movement_direction( act );
break;

case ACTION_MOVE_DOWN:
if( !u.in_vehicle ) {
vertical_move( -1, false );
Expand Down Expand Up @@ -1871,6 +1804,11 @@ bool game::handle_action()
}
break;

case ACTION_TOGGLE_AUTO_TRAVEL_MODE:
auto_travel_mode = !auto_travel_mode;
add_msg( m_info, auto_travel_mode ? _( "Auto travel mode ON!" ) : _( "Auto travel mode OFF!" ) );
break;

case ACTION_TOGGLE_SAFEMODE:
if( safe_mode == SAFE_MODE_OFF ) {
set_safe_mode( SAFE_MODE_ON );
Expand Down Expand Up @@ -2123,6 +2061,37 @@ bool game::handle_action()
default:
break;
}
if( dest_delta != point_zero ) {
if( !u.get_value( "remote_controlling" ).empty() &&
( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) {
rcdrive( dest_delta );
} else if( veh_ctrl ) {
pldrive( dest_delta );
} else {
if( auto_travel_mode ) {
for( int i = 0; i < SEEX; i++ ) {
tripoint auto_travel_destination( u.posx() + dest_delta.x * ( SEEX - i ),
u.posy() + dest_delta.y * ( SEEX - i ),
u.posz() );
destination_preview = m.route( u.pos(),
auto_travel_destination,
u.get_pathfinding_settings(),
u.get_path_avoid() );
if( !destination_preview.empty() ) {
u.set_destination( destination_preview );
break;
}
}
act = u.get_next_auto_move_direction();
point dest_next = get_delta_from_movement_direction( act );
if( dest_next == point_zero ) {
u.clear_destination();
}
dest_delta = dest_next;
}
continue_auto_move = plmove( dest_delta );
}
}
}
if( !continue_auto_move ) {
u.clear_destination();
Expand Down
4 changes: 2 additions & 2 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,8 @@ void player::update_bodytemp()
-1.5f * get_fatigue() ) );

// Sunlight
const int sunlight_warmth = g->is_in_sunlight( pos() ) ? 0 :
( g->weather == WEATHER_SUNNY ? 1000 : 500 );
const int sunlight_warmth = g->is_in_sunlight( pos() ) ? ( g->weather == WEATHER_SUNNY ? 1000 :
500 ) : 0;
const int best_fire = get_heat_radiation( pos(), true );

const int lying_warmth = use_floor_warmth ? floor_warmth( pos() ) : 0;
Expand Down
6 changes: 4 additions & 2 deletions src/rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool one_in( int chance )

bool x_in_y( double x, double y )
{
return rng_float( 0, y ) <= x;
return rng_float( 0.0, 1.0 ) <= x / y;
}

int dice( int number, int sides )
Expand All @@ -64,8 +64,10 @@ int roll_remainder( double value )
{
double integ;
double frac = modf( value, &integ );
if( value > integ && x_in_y( frac, 1.0 ) ) {
if( value > 0.0 && value > integ && x_in_y( frac, 1.0 ) ) {
integ++;
} else if( value < 0.0 && value < integ && x_in_y( -frac, 1.0 ) ) {
integ--;
}

return integ;
Expand Down
2 changes: 2 additions & 0 deletions src/savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void game::serialize( std::ostream &fout )
json.member( "turn", static_cast<int>( calendar::turn ) );
json.member( "calendar_start", static_cast<int>( calendar::start ) );
json.member( "initial_season", static_cast<int>( calendar::initial_season ) );
json.member( "auto_travel_mode", auto_travel_mode );
json.member( "run_mode", static_cast<int>( safe_mode ) );
json.member( "mostseen", mostseen );
// current map coordinates
Expand Down Expand Up @@ -186,6 +187,7 @@ void game::unserialize( std::istream &fin )
data.read( "calendar_start", tmpcalstart );
calendar::initial_season = static_cast<season_type>( data.get_int( "initial_season",
static_cast<int>( SPRING ) ) );
data.read( "auto_travel_mode", auto_travel_mode );
data.read( "run_mode", tmprun );
data.read( "mostseen", mostseen );
data.read( "levx", levx );
Expand Down