Skip to content

Commit

Permalink
Digitigrade Mutation Line-of-Sight Fix (#66764)
Browse files Browse the repository at this point in the history
* Update character.cpp

* Update lightmap.cpp

* Update mutations.json

* Update character.cpp

* Update character.h

* Update lightmap.cpp

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
GalacticApple and github-actions[bot] authored Jul 9, 2023
1 parent 243f468 commit a566717
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 4 additions & 3 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4003,7 +4003,8 @@
"and": [
{ "u_has_move_mode": "crouch" },
{ "not": "u_can_drop_weapon" },
{ "u_has_any_trait": [ "THRESH_LUPINE", "THRESH_FELINE", "THRESH_BEAST" ] }
{ "u_has_any_trait": [ "THRESH_LUPINE", "THRESH_FELINE", "THRESH_BEAST" ] },
{ "u_has_trait": "PAWS" }
]
},
"values": [ { "value": "MOVE_COST", "multiply": -0.15 }, { "value": "CARRY_WEIGHT", "multiply": 0.35 } ]
Expand All @@ -4026,12 +4027,12 @@
{ "u_has_move_mode": "walk" },
{
"and": [
{ "not": "u_can_drop_weapon" },
{ "not": { "u_has_trait": "THRESH_LUPINE" } },
{ "not": { "u_has_trait": "THRESH_FELINE" } },
{ "not": { "u_has_trait": "THRESH_BEAST" } }
]
}
},
{ "not": { "u_has_trait": "PAWS" } }
]
},
"values": [ { "value": "MOVE_COST", "multiply": -0.1 } ]
Expand Down
17 changes: 17 additions & 0 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ static const trait_id trait_SPIRITUAL( "SPIRITUAL" );
static const trait_id trait_STRONGBACK( "STRONGBACK" );
static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" );
static const trait_id trait_THORNS( "THORNS" );
static const trait_id trait_THRESH_BEAST( "THRESH_BEAST" );
static const trait_id trait_THRESH_FELINE( "THRESH_FELINE" );
static const trait_id trait_THRESH_LUPINE( "THRESH_LUPINE" );
static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" );
static const trait_id trait_TRANSPIRATION( "TRANSPIRATION" );
static const trait_id trait_URSINE_EYE( "URSINE_EYE" );
Expand Down Expand Up @@ -2020,6 +2023,20 @@ bool Character::is_crouching() const
return move_mode->type() == move_mode_type::CROUCHING;
}

bool Character::is_runallfours() const
{
bool allfour = false;
if( move_mode->type() == move_mode_type::RUNNING && !is_armed() ) {
if( has_trait( trait_PAWS ) && ( has_trait( trait_THRESH_LUPINE ) ||
has_trait( trait_THRESH_FELINE )
|| has_trait( trait_THRESH_BEAST ) ) ) {
allfour = true;
}
}

return allfour;
}

bool Character::is_prone() const
{
return move_mode->type() == move_mode_type::PRONE;
Expand Down
1 change: 1 addition & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ class Character : public Creature, public visitable
bool is_running() const;
bool is_walking() const;
bool is_crouching() const;
bool is_runallfours() const;
bool is_prone() const;

int footstep_sound() const;
Expand Down
3 changes: 2 additions & 1 deletion src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,13 @@ bool map::build_vision_transparency_cache( const int zlev )
bool dirty = false;

bool is_crouching = player_character.is_crouching();
bool is_runallfours = player_character.is_runallfours();
bool is_prone = player_character.is_prone();
for( const tripoint &loc : points_in_radius( p, 1 ) ) {
if( loc == p ) {
// The tile player is standing on should always be visible
vision_transparency_cache[p.x][p.y] = LIGHT_TRANSPARENCY_OPEN_AIR;
} else if( ( is_crouching || is_prone ) && coverage( loc ) >= 30 ) {
} else if( ( is_crouching || is_prone || is_runallfours ) && coverage( loc ) >= 30 ) {
// If we're crouching or prone behind an obstacle, we can't see past it.
vision_transparency_cache[loc.x][loc.y] = LIGHT_TRANSPARENCY_SOLID;
dirty = true;
Expand Down

0 comments on commit a566717

Please sign in to comment.