Skip to content

Commit

Permalink
Merge pull request #33329 from RedShakespeare/mech-defensive
Browse files Browse the repository at this point in the history
Adds new mon flag MECH_DEFENSIVE
  • Loading branch information
Rivet-the-Zombie authored Aug 19, 2019
2 parents 37826d1 + e1c35de commit 9b884d0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ Multiple death functions can be used. Not all combinations make sense.
- ```LEATHER``` May produce leather when butchered.
- ```LOUDMOVES``` Mkes move noises as if ~2 sizes louder, even if flying.
- ```MECH_RECON_VISION``` This mech grants you night-vision and enhanced overmap sight radius when piloted.
- ```MECH_DEFENSIVE``` This mech can protect you thoroughly when piloted.
- ```MILITARY_MECH``` Is a military-grade mech.
- ```MILKABLE``` Produces milk when milked.
- ```NIGHT_INVISIBILITY``` Monster becomes invisible if it's more than one tile away and the lighting on its tile is LL_LOW or less. Visibility is not affected by night vision.
Expand Down
25 changes: 17 additions & 8 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,15 @@ void Creature::deal_melee_hit( Creature *source, int hit_spread, bool critical_h
}
// If carrying a rider, there is a chance the hits may hit rider instead.
if( has_effect( effect_ridden ) ) {
// big mounts and small player = big shield for player.
if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) {
g->u.deal_melee_hit( source, hit_spread, critical_hit, dam, dealt_dam );
return;
if( !has_flag( MF_MECH_DEFENSIVE ) ) {
// If carrying a rider, there is a chance the hits may hit rider instead.
// big mounts and small player = big shield for player.
if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) {
g->u.deal_melee_hit( source, hit_spread, critical_hit, dam, dealt_dam );
return;
}
}
//otherwise it would thoroughly protect the rider(or pilot actually)
}
damage_instance d = dam; // copy, since we will mutate in block_hit
body_part bp_hit = select_body_part( source, hit_spread );
Expand Down Expand Up @@ -548,11 +552,16 @@ void Creature::deal_projectile_attack( Creature *source, dealt_projectile_attack
}
// If carrying a rider, there is a chance the hits may hit rider instead.
if( has_effect( effect_ridden ) ) {
// big mounts and small player = big shield for player.
if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) {
g->u.deal_projectile_attack( source, attack, print_messages );
return;
if( !has_flag( MF_MECH_DEFENSIVE ) ) {
// If carrying a rider, there is a chance the hits may hit rider instead.
// big mounts and small player = big shield for player.
if( one_in( std::max( 2, get_size() - g->u.get_size() ) ) ) {
g->u.deal_projectile_attack( source, attack, print_messages );
return;
}
}
//otherwise it would thoroughly protect the rider(or pilot actually)

}
const projectile &proj = attack.proj;
dealt_damage_instance &dealt_dam = attack.dealt_dam;
Expand Down
1 change: 1 addition & 0 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const std::map<std::string, m_flag> flag_map = {
{ "RIDEABLE_MECH", MF_RIDEABLE_MECH },
{ "MILITARY_MECH", MF_MILITARY_MECH },
{ "MECH_RECON_VISION", MF_MECH_RECON_VISION },
{ "MECH_DEFENSIVE", MF_MECH_DEFENSIVE },
{ "HIT_AND_RUN", MF_HIT_AND_RUN },
{ "GUILT", MF_GUILT },
{ "HUMAN", MF_HUMAN },
Expand Down
1 change: 1 addition & 0 deletions src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum m_flag : int {
MF_RIDEABLE_MECH, // A rideable mech that is immobile until ridden.
MF_MILITARY_MECH, // A rideable mech that was designed for military work.
MF_MECH_RECON_VISION, // This mech gives you IR night-vision.
MF_MECH_DEFENSIVE, // This mech gives you thorough protection.
MF_HIT_AND_RUN, // Flee for several turns after a melee attack
MF_GUILT, // You feel guilty for killing it
MF_HUMAN, // It's a live human, as long as it's alive
Expand Down

0 comments on commit 9b884d0

Please sign in to comment.