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

Adding a NO_SHOOT terrain Flag and example of use #45730

Merged
merged 3 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
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 @@ -3666,9 +3666,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 ) ) {
Maleclypse marked this conversation as resolved.
Show resolved Hide resolved
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