Skip to content

Commit

Permalink
Adding a NO_SHOOT terrain Flag and example of use (#45730)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maleclypse authored Dec 5, 2020
1 parent 170da18 commit 7717ee1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/mods/Magiclysm/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"color": "light_cyan",
"move_cost": 0,
"roof": "t_flat_roof",
"flags": [ "TRANSPARENT", "ALARMED", "NOITEM", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "BLOCK_WIND" ],
"flags": [ "TRANSPARENT", "ALARMED", "NOITEM", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "BLOCK_WIND", "NO_SHOOT" ],
"bash": {
"str_min": 200,
"str_max": 600,
Expand Down
9 changes: 6 additions & 3 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3668,9 +3668,12 @@ void map::shoot( const tripoint &p, projectile &proj, const bool hit_items )
};

ter_id terrain = ter( p );
if( terrain == t_wall_wood_broken ||
terrain == t_wall_log_broken ||
terrain == t_door_b ) {
if( terrain->has_flag( TFLAG_NO_SHOOT ) ) {
dam = 0.0f;
add_msg( _( "The shot is stopped by the %s" ), terrain->name() );
} else if( terrain == t_wall_wood_broken ||
terrain == t_wall_log_broken ||
terrain == t_door_b ) {
if( hit_items || one_in( 8 ) ) { // 1 in 8 chance of hitting the door
dam -= rng( 20, 40 );
if( dam > 0 ) {
Expand Down
1 change: 1 addition & 0 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static const std::unordered_map<std::string, ter_bitflags> ter_bitflags_map = {
{ "NO_SIGHT", TFLAG_NO_SIGHT }, // Sight reduced to 1 on this tile
{ "FLAMMABLE_ASH", TFLAG_FLAMMABLE_ASH }, // oh hey fire. again.
{ "WALL", TFLAG_WALL }, // connects to other walls
{ "NO_SHOOT", TFLAG_NO_SHOOT }, // terrain cannot be damaged by ranged attacks
{ "NO_SCENT", TFLAG_NO_SCENT }, // cannot have scent values, which prevents scent diffusion through this tile
{ "DEEP_WATER", TFLAG_DEEP_WATER }, // Deep enough to submerge things
{ "SHALLOW_WATER", TFLAG_SHALLOW_WATER }, // Water, but not deep enough to submerge the player
Expand Down
1 change: 1 addition & 0 deletions src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ enum ter_bitflags : int {
TFLAG_WALL,
TFLAG_DEEP_WATER,
TFLAG_SHALLOW_WATER,
TFLAG_NO_SHOOT,
TFLAG_CURRENT,
TFLAG_HARVESTED,
TFLAG_PERMEABLE,
Expand Down

0 comments on commit 7717ee1

Please sign in to comment.