Skip to content

Commit

Permalink
activation consume (#60502)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirmuolio committed Aug 28, 2022
1 parent f8c7e6f commit 1f6dbbc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/activity_handlers.cpp
Expand Up @@ -1667,7 +1667,7 @@ void activity_handlers::start_fire_finish( player_activity *act, Character *you
return;
}

it.ammo_consume( 1, you->pos(), you );
it.activation_consume( 1, you->pos(), you );

you->practice( skill_survival, act->index, 5 );

Expand Down
4 changes: 2 additions & 2 deletions src/character.cpp
Expand Up @@ -6508,11 +6508,11 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi

if( actually_used->is_comestible() ) {
const bool ret = consume_effects( *used );
actually_used->ammo_consume( charges_used.value(), pt, this );
actually_used->activation_consume( charges_used.value(), pt, this );
return ret;
}

actually_used->ammo_consume( charges_used.value(), pt, this );
actually_used->activation_consume( charges_used.value(), pt, this );

if( actually_used->has_flag( flag_SINGLE_USE ) || actually_used->is_bionic() ||
actually_used->is_deployable() ) {
Expand Down
5 changes: 5 additions & 0 deletions src/item.cpp
Expand Up @@ -10890,6 +10890,11 @@ int item::ammo_consume( int qty, const tripoint &pos, Character *carrier )
return wanted_qty - qty;
}

int item::activation_consume( int qty, const tripoint &pos, Character *carrier )
{
return ammo_consume( qty * ammo_required(), pos, carrier );
}

const itype *item::ammo_data() const
{
const item *mag = magazine_current();
Expand Down
10 changes: 10 additions & 0 deletions src/item.h
Expand Up @@ -2294,6 +2294,16 @@ class item : public visitable
*/
int ammo_consume( int qty, const tripoint &pos, Character *carrier );

/**
* Consume ammo to activate item qty times (if available) and return the amount of ammo that was consumed
* Consume order: loaded items, UPS, bionic
* @param qty number of times to consume item activation charges
* @param pos current location of item, used for ejecting magazines and similar effects
* @param carrier holder of the item, used for getting UPS and bionic power
* @return amount of ammo consumed which will be between 0 and qty
*/
int activation_consume( int qty, const tripoint &pos, Character *carrier );

/** Specific ammo data, returns nullptr if item is neither ammo nor loaded with any */
const itype *ammo_data() const;
/** Specific ammo type, returns "null" if item is neither ammo nor loaded with any */
Expand Down
2 changes: 1 addition & 1 deletion src/trapfunc.cpp
Expand Up @@ -1262,7 +1262,7 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * )
if( jetpack.ammo_sufficient( you ) ) {
you->add_msg_player_or_npc( _( "You ignite your %s and use it to break the fall." ),
_( "<npcname> uses their %s to break the fall." ), jetpack.tname() );
jetpack.ammo_consume( 1, you->pos(), you );
jetpack.activation_consume( 1, you->pos(), you );
} else {
you->add_msg_if_player( m_bad,
_( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() );
Expand Down

0 comments on commit 1f6dbbc

Please sign in to comment.