Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
robob27 committed Dec 5, 2022
1 parent 0d44b0e commit 93cb01f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 28 deletions.
1 change: 0 additions & 1 deletion data/json/items/melee/unarmed_weapons.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"bashing": 4,
"price_postapoc": 50,
"qualities": [ [ "HAMMER", 1 ] ],
"flags": [ "UNARMED_WEAPON" ],
"material_thickness": 1,
"armor": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ class Character : public Creature, public visitable
/** How much dispersion does one point of target's dodge add when throwing at said target? */
int throw_dispersion_per_dodge( bool add_encumbrance = true ) const;

/** True if unarmed or wielding a weapon with the UNARMED_WEAPON flag */
/** True if unarmed */
bool unarmed_attack() const;
/// Checks for items, tools, and vehicles with the Lifting quality near the character
/// returning the largest weight liftable by an item in range.
Expand Down
10 changes: 0 additions & 10 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ static const quality_id qual_LIFT( "LIFT" );
static const skill_id skill_cooking( "cooking" );
static const skill_id skill_melee( "melee" );
static const skill_id skill_survival( "survival" );
static const skill_id skill_unarmed( "unarmed" );
static const skill_id skill_weapon( "weapon" );

static const species_id species_ROBOT( "ROBOT" );
Expand Down Expand Up @@ -851,11 +850,6 @@ bool item::is_null() const
return ( type == nullptr || type == nullitem() || typeId().is_null() );
}

bool item::is_unarmed_weapon() const
{
return is_null() || has_flag( flag_UNARMED_WEAPON );
}

bool item::is_frozen_liquid() const
{
return made_of( phase_id::SOLID ) && made_of_from_type( phase_id::LIQUID );
Expand Down Expand Up @@ -10587,10 +10581,6 @@ gun_type_type item::gun_type() const

skill_id item::melee_skill() const
{
if( is_unarmed_weapon() ) {
return skill_unarmed;
}

if( !is_melee() ) {
return skill_id::NULL_ID();
}
Expand Down
2 changes: 0 additions & 2 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,6 @@ class item : public visitable
/** Returns true if the item is broken or will be broken on activation */
bool is_broken_on_active() const;

bool is_unarmed_weapon() const; //Returns true if the item should be considered unarmed

bool has_temperature() const;

/** Returns true if the item is A: is SOLID and if it B: is of type LIQUID */
Expand Down
9 changes: 1 addition & 8 deletions src/martialarts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static const bionic_id bio_armor_arms( "bio_armor_arms" );
static const bionic_id bio_armor_legs( "bio_armor_legs" );
static const bionic_id bio_cqb( "bio_cqb" );

static const flag_id json_flag_UNARMED_WEAPON( "UNARMED_WEAPON" );
static const json_character_flag json_flag_ALWAYS_BLOCK( "ALWAYS_BLOCK" );
static const json_character_flag json_flag_NONSTANDARD_BLOCK( "NONSTANDARD_BLOCK" );

Expand Down Expand Up @@ -620,15 +619,13 @@ bool ma_requirements::is_valid_character( const Character &u ) const
bool melee_style = u.martial_arts_data->selected_strictly_melee();
bool is_armed = u.is_armed();
bool forced_unarmed = u.martial_arts_data->selected_force_unarmed();
bool unarmed_weapon = is_armed && !forced_unarmed && weapon->has_flag( json_flag_UNARMED_WEAPON );
bool weapon_ok = melee_allowed && weapon && is_valid_weapon( *weapon );
bool style_weapon = weapon && u.martial_arts_data->selected_has_weapon( weapon->typeId() );
bool all_weapons = u.martial_arts_data->selected_allow_all_weapons();

bool unarmed_ok = !is_armed || ( unarmed_weapon && unarmed_weapons_allowed );
bool melee_ok = weapon_ok && ( style_weapon || all_weapons );

bool valid_unarmed = !melee_style && unarmed_allowed && unarmed_ok;
bool valid_unarmed = !melee_style && unarmed_allowed && !is_armed;
bool valid_melee = !strictly_unarmed && ( forced_unarmed || melee_ok );

if( !valid_unarmed && !valid_melee ) {
Expand Down Expand Up @@ -1283,10 +1280,6 @@ bool martialart::weapon_valid( const item_location &it ) const
return true;
}

if( !strictly_unarmed && !strictly_melee && it && it->has_flag( json_flag_UNARMED_WEAPON ) ) {
return true;
}

return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ bool Character::is_armed() const
bool Character::unarmed_attack() const
{
const item_location weap = used_weapon();
return !weap || weap->has_flag( flag_UNARMED_WEAPON );
return !weap;
}

bool Character::handle_melee_wear( item_location shield, float wear_multiplier )
Expand Down Expand Up @@ -451,7 +451,7 @@ static void melee_train( Character &you, int lo, int hi, const item &weap )
float total = std::max( cut + stab + bash, 1 );

// Unarmed may deal cut, stab, and bash damage depending on the weapon
if( weap.is_unarmed_weapon() ) {
if( you.unarmed_attack() ) {
you.practice( skill_unarmed, std::ceil( 1 * rng( lo, hi ) ), hi );
} else {
you.practice( skill_cutting, std::ceil( cut / total * rng( lo, hi ) ), hi );
Expand Down Expand Up @@ -1050,7 +1050,7 @@ double Character::crit_chance( float roll_hit, float target_dodge, const item &w

// Weapon to-hit roll
double weapon_crit_chance = 0.5;
if( weap.is_unarmed_weapon() ) {
if( unarmed_attack() ) {
// Unarmed attack: 1/2 of unarmed skill is to-hit
/** @EFFECT_UNARMED increases critical chance with UNARMED_WEAPON */
weapon_crit_chance = 0.5 + 0.05 * get_skill_level( skill_unarmed );
Expand Down Expand Up @@ -2188,7 +2188,7 @@ bool Character::block_hit( Creature *source, bodypart_id &bp_hit, damage_instanc
bool worn_shield = has_shield && shield->has_flag( flag_BLOCK_WHILE_WORN );

bool conductive_shield = false;
bool unarmed = !is_armed() || weapon.has_flag( flag_UNARMED_WEAPON );
bool unarmed = !is_armed();
bool force_unarmed = martial_arts_data->is_force_unarmed();
bool allow_weapon_blocking = martial_arts_data->can_weapon_block();

Expand Down
3 changes: 1 addition & 2 deletions src/npc_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ bool npc_attack_throw::can_use( const npc &source ) const
bool throwable = source.throw_range( single_item ) > 0 && !source.is_worn( thrown_item ) &&
!thrown_item.has_flag( flag_NPC_ACTIVATE );
throwable = throwable && !thrown_item.is_gun() && !thrown_item.is_armor() &&
!thrown_item.is_comestible() && !thrown_item.is_magazine() && !thrown_item.is_tool() &&
!thrown_item.is_unarmed_weapon();
!thrown_item.is_comestible() && !thrown_item.is_magazine() && !thrown_item.is_tool();
// TODO: Better choose what should be thrown
return throwable;
}
Expand Down

0 comments on commit 93cb01f

Please sign in to comment.