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

feat: Add Lua bindings to toggle mutations on/off #5762

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/catalua_bindings_creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ void cata::detail::reg_character( sol::state &lua )
SET_FX_T( set_mutation, void( const trait_id & ) );
SET_FX_T( unset_mutation, void( const trait_id & ) );

SET_FX_T( activate_mutation, void( const trait_id & ) );
SET_FX_T( deactivate_mutation, void( const trait_id & ) );

SET_FX_T( can_mount, bool( const monster & critter ) const );
SET_FX_T( mount_creature, void( monster & z ) );
SET_FX_T( is_mounted, bool() const );
Expand Down
10 changes: 10 additions & 0 deletions src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ bool Character::can_install_cbm_on_bp( const std::vector<bodypart_id> &bps ) con

void Character::activate_mutation( const trait_id &mut )
{
// Make sure we actually have the mutation, and it's inactive.
if( !( has_trait( mut ) && !my_mutations[mut].powered ) ) {
return;
}

const mutation_branch &mdata = mut.obj();
char_trait_data &tdata = my_mutations[mut];
// You can take yourself halfway to Near Death levels of hunger/thirst.
Expand Down Expand Up @@ -593,6 +598,11 @@ void Character::activate_mutation( const trait_id &mut )

void Character::deactivate_mutation( const trait_id &mut )
{
// No-op if we don't have the required mutation.
if( !has_active_mutation( mut ) ) {
return;
}

my_mutations[mut].powered = false;

// Handle stat changes from deactivation
Expand Down
Loading