Skip to content

Commit

Permalink
Merge branch 'kevingranade-sharing-plows' of https://github.com/Bevap…
Browse files Browse the repository at this point in the history
…Din/Cataclysm-DDA into sharing-plows

Conflicts:
	data/json/recipes/recipe_others.json
	data/json/vehicles/farm.json
	src/map.cpp
	src/vehicle.cpp
  • Loading branch information
kevingranade committed Sep 25, 2015
2 parents 8696e6a + a0a5046 commit aeb55a0
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 151 deletions.
2 changes: 1 addition & 1 deletion data/json/recipes/recipe_others.json
Original file line number Diff line number Diff line change
Expand Up @@ -7807,7 +7807,7 @@
"difficulty": 5,
"time": 10000,
"reversible": true,
"autolearn": true,
"autolearn": false,
"qualities":[
{"id":"HAMMER","level":2,"amount":1},
{"id":"SAW_M","level":1,"amount":1}
Expand Down
234 changes: 111 additions & 123 deletions data/json/vehicles/farm.json
Original file line number Diff line number Diff line change
@@ -1,130 +1,118 @@
[
{
"type":"vehicle",
"id":"tractor_seed",
"name":"Planter Tractor",
"blueprint":[
["& "],
["&OO O"],
["&HH===#|"],
["&OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"frame_cross"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"frame_cross"},
{"x":-3,"y":-2,"part":"frame_cross"},
{"x":-4,"y":0,"part":"seed_drill"},
{"x":-4,"y":1,"part":"seed_drill"},
{"x":-4,"y":-1,"part":"seed_drill"},
{"x":-4,"y":2,"part":"seed_drill"},
{"x":-4,"y":-2,"part":"seed_drill"}
],
"items":[]
"type":"vehicle",
"id":"tractor_seed",
"name":"Planter Tractor",
"blueprint":[
["& "],
["+OO O"],
["&HH===#|"],
["+OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"seed_drill"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"seed_drill"},
{"x":-3,"y":-2,"part":"seed_drill"}
],
"items":[]
},{
"type":"vehicle",
"id":"tractor_plow",
"name":"Plow Tractor",
"blueprint":[
["& "],
["&OO O"],
["&HH===#|"],
["&OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"frame_cross"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"frame_cross"},
{"x":-3,"y":-2,"part":"frame_cross"},
{"x":-3,"y":0,"part":"plow"},
{"x":-3,"y":1,"part":"plow"},
{"x":-3,"y":-1,"part":"plow"},
{"x":-3,"y":2,"part":"plow"},
{"x":-3,"y":-2,"part":"plow"}
],
"items":[]
"type":"vehicle",
"id":"tractor_plow",
"name":"Plow Tractor",
"blueprint":[
["& "],
["+OO O"],
["&HH===#|"],
["+OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"frame_cross"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"frame_cross"},
{"x":-3,"y":-2,"part":"frame_cross"},
{"x":-3,"y":0,"part":"plow"},
{"x":-3,"y":2,"part":"plow"},
{"x":-3,"y":-2,"part":"plow"}
],
"items":[]
},
{
"type":"vehicle",
"id":"tractor_reaper",
"name":"Reaper Tractor",
"blueprint":[
["& "],
["&OO O"],
["&HH===#|"],
["&OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"frame_cross"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"frame_cross"},
{"x":-3,"y":-2,"part":"frame_cross"},
{"x":-4,"y":0,"part":"reaper"},
{"x":-4,"y":1,"part":"reaper"},
{"x":-4,"y":-1,"part":"reaper"},
{"x":-4,"y":2,"part":"reaper"},
{"x":-4,"y":-2,"part":"reaper"}
],
"items":[]
"type":"vehicle",
"id":"tractor_reaper",
"name":"Reaper Tractor",
"blueprint":[
["& "],
["+OO O"],
["&HH===#|"],
["+OO O"],
["& "]
],
"parts":[
{"x":0,"y":0,"part":"frame_horizontal"},
{"x":0,"y":0,"part":"battery_truck"},
{"x":0,"y":-1,"part":"frame_horizontal"},
{"x":0,"y":1,"part":"frame_horizontal"},
{"x":0,"y":-1,"part":"wheel_wide"},
{"x":0,"y":1,"part":"wheel_wide"},
{"x":0,"y":0,"part":"halfboard_horizontal"},
{"x":-1,"y":0,"part":"frame_vertical"},
{"x":-1,"y":0,"part":"seat"},
{"x":-1,"y":0,"part":"controls"},
{"x":-2,"y":0,"part":"frame_cross"},
{"x":-2,"y":0,"part":"diesel_tank"},
{"x":0,"y":0,"part":"diesel_engine_v8"},
{"x":0,"y":0,"part":"alternator_truck"},
{"x":-2,"y":1,"part":"frame_horizontal"},
{"x":-2,"y":-1,"part":"frame_horizontal"},
{"x":-2,"y":1,"part":"wheel_wide"},
{"x":-2,"y":-1,"part":"wheel_wide"},
{"x":-3,"y":0,"part":"reaper"},
{"x":-3,"y":1,"part":"frame_cross"},
{"x":-3,"y":-1,"part":"frame_cross"},
{"x":-3,"y":2,"part":"reaper"},
{"x":-3,"y":-2,"part":"reaper"}
],
"items":[]
}
]
62 changes: 40 additions & 22 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,41 @@ void iexamine::dirtmound(player *p, map *m, const tripoint &examp)
add_msg(_("Planted %s"), seed_names[seed_index].c_str());
}

std::list<item> iexamine::get_harvest_items( const itype &type, const int plant_count,
const int seed_count, const bool byproducts )
{
std::list<item> result;
if( !type.seed ) {
return result;
}
const islot_seed &seed_data = *type.seed;
const itype_id &seed_type = type.id;

const auto add = [&]( const itype_id &id, const int count ) {
item new_item( id, calendar::turn );
if( new_item.count_by_charges() && count > 0 ) {
new_item.charges = count;
result.push_back( new_item );
} else if( count > 0 ) {
result.insert( result.begin(), count, new_item );
}
};

if( seed_data.spawn_seeds ) {
add( seed_type, seed_count );
}

add( seed_data.fruit_id, plant_count );

if( byproducts ) {
for( auto &b : seed_data.byproducts ) {
add( b, 1 );
}
}

return result;
}

void iexamine::aggie_plant(player *p, map *m, const tripoint &examp)
{
if( m->i_at( examp ).empty() ) {
Expand All @@ -1601,7 +1636,6 @@ void iexamine::aggie_plant(player *p, map *m, const tripoint &examp)
const std::string pname = seed.get_plant_name();

if (m->furn(examp) == f_plant_harvest && query_yn(_("Harvest the %s?"), pname.c_str() )) {
const islot_seed &seed_data = *seed.type->seed;
const std::string &seedType = seed.typeId();
if (seedType == "fungal_seeds") {
fungus(p, m, examp);
Expand All @@ -1613,7 +1647,7 @@ void iexamine::aggie_plant(player *p, map *m, const tripoint &examp)
m->ter_set(examp, t_marloss);
add_msg(m_info, _("We have altered this unit's configuration to extract and provide local nutriment. The Mycus provides."));
} else if ( (p->has_trait("M_DEFENDER")) || ( (p->has_trait("M_SPORES") || p->has_trait("M_FERTILE")) &&
one_in(2)) ) {
one_in(2)) ) {
// Note: not Z-level-friendly!
g->summon_mon( mon_fungal_blossom, examp );
add_msg(m_info, _("The seed blooms forth! We have brought true beauty to this world."));
Expand All @@ -1625,6 +1659,7 @@ void iexamine::aggie_plant(player *p, map *m, const tripoint &examp)
add_msg(m_info, _("The seed blossoms into a flower-looking fungus."));
}
} else { // Generic seed, use the seed item data
const itype &type = *seed.type;
m->i_clear(examp);
m->furn_set(examp, f_null);

Expand All @@ -1635,26 +1670,9 @@ void iexamine::aggie_plant(player *p, map *m, const tripoint &examp)
} else if( plantCount <= 0 ) {
plantCount = 1;
}
item tmp;
if( seed_data.spawn_seeds ) {
tmp = item( seedType, calendar::turn );
const int seedCount = std::max( 1l, rng( plantCount / 4, plantCount / 2 ) );
if( tmp.count_by_charges() ) {
tmp.charges = 1;
}
for( int i = 0; i < seedCount; ++i ) {
m->add_item_or_charges( examp, tmp );
}
}
tmp = item( seed_data.fruit_id, calendar::turn );
if( tmp.count_by_charges() ) {
tmp.charges = 1;
}
for( int i = 0; i < plantCount; ++i ) {
m->add_item_or_charges( examp, tmp );
}
for( auto &b : seed_data.byproducts ) {
m->spawn_item( examp, b, 1, 1, calendar::turn );
const int seedCount = std::max( 1l, rng( plantCount / 4, plantCount / 2 ) );
for( auto &i : get_harvest_items( type, plantCount, seedCount, true ) ) {
m->add_item_or_charges( examp, i );
}
p->moves -= 500;
}
Expand Down
12 changes: 12 additions & 0 deletions src/iexamine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define IEXAMINE_H

#include <string>
#include <list>

#include "string_id.h"

Expand All @@ -17,6 +18,7 @@ class item;
class player;
class map;
struct tripoint;
struct itype;
struct mtype;
using mtype_id = string_id<mtype>;

Expand Down Expand Up @@ -94,6 +96,16 @@ void sign( player *p, map *m, const tripoint &examp );
void pay_gas( player *p, map *m, const tripoint &examp );
void climb_down( player *p, map *m, const tripoint &examp );

/**
* Items that appear when a generic plant is harvested. Seed @ref islot_seed.
* @param type The seed type, must have a @ref itype::seed slot.
* @param plant_count Number of fruits to generate.
* @param seed_count Number of seeds to generate.
* @param byproducts If true, byproducts (like straw, withered plants, see
* @ref islot_seed::byproducts) are included.
*/
std::list<item> get_harvest_items( const itype &type, int plant_count,
int seed_count, bool byproducts );
} //namespace iexamine

using iexamine_function = void ( * )( player *, map *, const tripoint & );
Expand Down
3 changes: 0 additions & 3 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,6 @@ void map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing
veh.skidding = true;
veh.turn( coll_turn );
}
// accept new position
// if submap changed, we need to process grid from the beginning.
// TODO: Allow vehicles to get displaced vertically
veh.on_move();
// Actually change position
displace_vehicle( pt, dp );
Expand Down
Loading

0 comments on commit aeb55a0

Please sign in to comment.