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

Make consuming take time #40117

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3838c3b
Add spurge seeds
Rail-Runner May 1, 2020
e7e2d87
Add item groups
Rail-Runner May 1, 2020
a1110ab
Works with constant 5 minute time
Ramza13 May 3, 2020
cf091cc
Get time set correctly and containers handeld and medicine
Ramza13 May 4, 2020
8d058cb
Fix verb
Ramza13 May 4, 2020
0b9c3f2
Formatting
Ramza13 May 4, 2020
314b291
Merge branch 'master' into consume_time
Ramza13 May 4, 2020
9200334
Hopefully fix all pockets conflicts
Ramza13 May 4, 2020
4fa8898
Merge branch 'consume_time' of https://github.com/Ramza13/Cataclysm-D…
Ramza13 May 4, 2020
65f527b
Fix merge conflict
Ramza13 May 4, 2020
3bd3a9d
Fix build
Ramza13 May 4, 2020
d31e9bc
Build fix once more
Ramza13 May 4, 2020
b4cbba5
Fix crafting iteminfo test
kevingranade May 4, 2020
2ebad2a
storage definition hotfix
kevingranade May 4, 2020
0c4d9b2
Merge pull request #40049 from Rail-Runner/plants3
Rivet-the-Zombie May 4, 2020
8cc6f88
Migrate inventory_ui.cpp and game_inventory.cpp to ui_adaptor
Qrox May 1, 2020
6b7fa02
map fixes (#40113)
curstwist May 4, 2020
141e5ff
Update materials for bullet damage type (#40112)
anothersimulacrum May 4, 2020
54afa14
Consume menu fix (#40108)
KorGgenT May 4, 2020
7ba9c31
Merge pull request #40123 from kevingranade/fix-iteminfo-crafting-test
ZhilkinSerg May 4, 2020
5ed7427
CFRelease CFString objects
akirashirosawa May 4, 2020
6d444b8
Make point and tripoint abs functions into methods. (#40106)
kevingranade May 4, 2020
6f79dc9
Merge pull request #40094 from Qrox/migrate-ui-12
ZhilkinSerg May 4, 2020
7780822
Merge pull request #40131 from akirashirosawa/fix-macos-memory-leak
ZhilkinSerg May 4, 2020
64d8209
Remove uneeded code
Ramza13 May 4, 2020
63bbe9a
Fix style issue
Ramza13 May 4, 2020
0c29d97
Code review suggestions
Ramza13 May 4, 2020
b305853
Merge branch 'consume_time' of https://github.com/Ramza13/Cataclysm-D…
Ramza13 May 4, 2020
2a7e0de
Code review changes/rebase
Ramza13 May 4, 2020
8911bad
Formatting
Ramza13 May 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get time set correctly and containers handeld and medicine
  • Loading branch information
Ramza13 committed May 4, 2020
commit cf091ccc86e045369ffbc7a7e2586e5660860522
2 changes: 1 addition & 1 deletion src/achievement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ std::string achievement_tracker::ui_text() const
achievement_completion::failed,
achievement_->time_constraint()->target(),
current_values()
}. ui_text( achievement_ );
} . ui_text( achievement_ );
}

// First: the achievement name and description
Expand Down
29 changes: 24 additions & 5 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "npc.h"
#include "output.h"
#include "pickup.h"
#include "player.h"
#include "player_activity.h"
#include "point.h"
#include "timed_event.h"
Expand All @@ -33,6 +34,8 @@ static const skill_id skill_computer( "computer" );

static const trait_id trait_ILLITERATE( "ILLITERATE" );

static const std::string flag_USE_EAT_VERB( "USE_EAT_VERB" );

void hacking_activity_actor::start( player_activity &act, Character & )
{
act.moves_total = to_moves<int>( 5_minutes );
Expand Down Expand Up @@ -409,16 +412,32 @@ std::unique_ptr<activity_actor> open_gate_activity_actor::deserialize( JsonIn &j
return actor.clone();
}

void consume_activity_actor::start( player_activity &act, Character & )
void consume_activity_actor::start( player_activity &act, Character &who )
{
act.moves_total = to_moves<int>( 5_minutes );
act.moves_left = to_moves<int>( 5_minutes );
item &comest = who.get_consumable_from( *loc.get_item() );
Ramza13 marked this conversation as resolved.
Show resolved Hide resolved

const int charges = std::max( comest.charges, 1 );
int volume = units::to_milliliter( comest.volume() ) / charges;
Ramza13 marked this conversation as resolved.
Show resolved Hide resolved
int time = 0;
Ramza13 marked this conversation as resolved.
Show resolved Hide resolved
const bool eat_verb = comest.has_flag( flag_USE_EAT_VERB );
if( eat_verb || comest.get_comestible()->comesttype == "FOOD" ) {
time = volume / 5;//Eat 5 mL (1 teaspoon) per second
} else if( !eat_verb && comest.get_comestible()->comesttype == "DRINK" ) {
time = volume / 15;//Drink 15 mL (1 tablespoon) per second
} else if( comest.is_medication() ) {
time = 30;//Medicine/drugs takes 30 seconds this is pretty arbitrary and should probable be broken up more but seems ok for a start
} else {
debugmsg( "Consumed something that was not food, drink or medicine/drugs" );
}

act.moves_total = time;
act.moves_left = time;
}

void consume_activity_actor::do_turn( player_activity &act, Character & )
{
act.moves_left = act.moves_left-1;
g->u.moves -= 1;
act.moves_left = act.moves_left - 1;
g->u.moves -= 100;
Ramza13 marked this conversation as resolved.
Show resolved Hide resolved
}

void consume_activity_actor::finish( player_activity &act, Character &who )
Expand Down
3 changes: 0 additions & 3 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,19 +3059,16 @@ void activity_handlers::eat_menu_do_turn( player_activity *, player * )

void activity_handlers::consume_food_menu_do_turn( player_activity *, player *p )
{
p->cancel_activity();
avatar_action::eat( g->u, game_menus::inv::consume_food( g->u ) );
}

void activity_handlers::consume_drink_menu_do_turn( player_activity *, player *p )
{
p->cancel_activity();
avatar_action::eat( g->u, game_menus::inv::consume_drink( g->u ) );
}

void activity_handlers::consume_meds_menu_do_turn( player_activity *, player *p )
{
p->cancel_activity();
avatar_action::eat( g->u, game_menus::inv::consume_meds( g->u ) );
}

Expand Down
6 changes: 3 additions & 3 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,9 @@ void avatar_action::eat( avatar &you, item_location loc )
return;
}

you.assign_activity( player_activity( consume_activity_actor(
loc
) ) );
you.assign_activity( player_activity( consume_activity_actor(
loc
) ) );
}

void avatar_action::plthrow( avatar &you, item_location loc,
Expand Down
6 changes: 4 additions & 2 deletions src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,9 +2789,11 @@ void target_ui::draw_controls_list( int text_y )
}
if( mode == TargetMode::Fire || mode == TargetMode::TurretManual ) {
lines.push_back( {5, colored( col_enabled, string_format( _( "[%c] to switch firing modes." ),
bound_key( "SWITCH_MODE" ) ) )} );
bound_key( "SWITCH_MODE" ) ) )
} );
lines.push_back( {6, colored( col_enabled, string_format( _( "[%c] to reload/switch ammo." ),
bound_key( "SWITCH_AMMO" ) ) )} );
bound_key( "SWITCH_AMMO" ) ) )
} );
}

// Shrink the list until it fits
Expand Down