Skip to content

Commit

Permalink
Debug Menu / Set HP
Browse files Browse the repository at this point in the history
  • Loading branch information
Venera3 committed Jan 20, 2024
1 parent 735d983 commit 561576d
Showing 1 changed file with 20 additions and 46 deletions.
66 changes: 20 additions & 46 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,60 +1603,34 @@ static void character_edit_needs_menu( Character &you )

static void character_edit_hp_menu( Character &you )
{
const int torso_hp = you.get_part_hp_cur( bodypart_id( "torso" ) );
const int head_hp = you.get_part_hp_cur( bodypart_id( "head" ) );
const int arm_l_hp = you.get_part_hp_cur( bodypart_id( "arm_l" ) );
const int arm_r_hp = you.get_part_hp_cur( bodypart_id( "arm_r" ) );
const int leg_l_hp = you.get_part_hp_cur( bodypart_id( "leg_l" ) );
const int leg_r_hp = you.get_part_hp_cur( bodypart_id( "leg_r" ) );
uilist smenu;
smenu.addentry( 0, true, 'q', "%s: %d", _( "Torso" ), torso_hp );
smenu.addentry( 1, true, 'w', "%s: %d", _( "Head" ), head_hp );
smenu.addentry( 2, true, 'a', "%s: %d", _( "Left arm" ), arm_l_hp );
smenu.addentry( 3, true, 's', "%s: %d", _( "Right arm" ), arm_r_hp );
smenu.addentry( 4, true, 'z', "%s: %d", _( "Left leg" ), leg_l_hp );
smenu.addentry( 5, true, 'x', "%s: %d", _( "Right leg" ), leg_r_hp );
smenu.addentry( 6, true, 'e', "%s: %d", _( "All" ), you.get_lowest_hp() );
int pos = 0;
char hotkey = 'a';
std::vector<bodypart_id> part_ids = you.get_all_body_parts( get_body_part_flags::only_main );
for( bodypart_id part_id : part_ids ) {
smenu.addentry( pos, true, hotkey, "%s: %d", part_id->name, you.get_part_hp_cur( part_id ) );
pos++;
hotkey++;
}
smenu.addentry( pos, true, hotkey, "%s: %d", _( "All" ), you.get_lowest_hp() );
part_ids.push_back( body_part_bp_null );
smenu.query();
bodypart_str_id bp = body_part_no_a_real_part;
int bp_ptr = -1;
bool all_select = false;

switch( smenu.ret ) {
case 0:
bp = body_part_torso;
bp_ptr = torso_hp;
break;
case 1:
bp = body_part_head;
bp_ptr = head_hp;
break;
case 2:
bp = body_part_arm_l;
bp_ptr = arm_l_hp;
break;
case 3:
bp = body_part_arm_r;
bp_ptr = arm_r_hp;
break;
case 4:
bp = body_part_leg_l;
bp_ptr = leg_l_hp;
break;
case 5:
bp = body_part_leg_r;
bp_ptr = leg_r_hp;
break;
case 6:
all_select = true;
break;
default:
break;
if( smenu.ret > part_ids.size() ) {
return;
}
bp = part_ids.at( smenu.ret ).id();
if( bp == body_part_bp_null ) {
all_select = true;
}

if( bp.is_valid() ) {
if( bp.is_valid() && bp != body_part_bp_null ) {
int value;
if( query_int( value, _( "Set the hitpoints to? Currently: %d" ), bp_ptr ) && value >= 0 ) {
if( query_int( value, _( "Set the hitpoints to? Currently: %d" ),
you.get_part_hp_cur( bp.id() ) ) &&
value >= 0 ) {
you.set_part_hp_cur( bp.id(), value );
you.reset_stats();
}
Expand Down

0 comments on commit 561576d

Please sign in to comment.