From 183ea4f4730a631651198a90236097e182afbea0 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 19 Dec 2020 21:33:47 +0100 Subject: [PATCH 01/23] Poison+Test --- src/monster.cpp | 19 ++++--- tests/creature_effect_test.cpp | 92 ++++++++++++++++++++++------------ 2 files changed, 70 insertions(+), 41 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index e9cade56fb5f1..fe3adf868abe5 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -88,6 +88,8 @@ static const efftype_id effect_run( "run" ); static const efftype_id effect_stunned( "stunned" ); static const efftype_id effect_supercharged( "supercharged" ); static const efftype_id effect_tied( "tied" ); +static const efftype_id effect_venom_dmg( "venom_dmg" ); +static const efftype_id effect_venom_weaken( "venom_weaken" ); static const efftype_id effect_webbed( "webbed" ); static const itype_id itype_corpse( "corpse" ); @@ -1289,9 +1291,11 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_paralyzepoison || effect == effect_badpoison || + effect == effect_venom_dmg || + effect == effect_venom_weaken || effect == effect_poison ) { - return !has_flag( MF_WARM ) || - ( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ) ); + return type->in_species( species_ZOMBIE ) || + !made_of_any( Creature::cmat_flesh ); } if( effect == effect_stunned ) { @@ -1362,16 +1366,15 @@ void monster::melee_attack( Creature &target ) void monster::melee_attack( Creature &target, float accuracy ) { - // Note: currently this method must consume move even if attack hasn't actually happen - // otherwise infinite loop will happen + int hitspread = target.deal_melee_attack( this, melee::melee_hit_range( accuracy ) ); mod_moves( -type->attack_cost ); - if( /*This happens sometimes*/ this == &target || !is_adjacent( &target, true ) ) { + if( type->melee_dice == 0 ) { + // We don't attack, so just return return; } - int hitspread = target.deal_melee_attack( this, melee::melee_hit_range( accuracy ) ); - if( type->melee_dice == 0 ) { - // We don't attack, so just return + if( this == &target ) { + // This happens sometimes return; } diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index a760460ed1b5d..86666dd6898a5 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -8,6 +8,8 @@ #include "mtype.h" #include "type_id.h" +static const species_id species_ZOMBIE( "ZOMBIE" ); + // Test effect methods from `Creature` class on both `monster` and `player` // Functions covered: @@ -352,50 +354,52 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) const efftype_id effect_poison( "poison" ); const efftype_id effect_badpoison( "badpoison" ); const efftype_id effect_paralyzepoison( "paralyzepoison" ); + const efftype_id effect_venom_dmg( "venom_dmg" ); + const efftype_id effect_venom_weaken( "venom_weaken" ); // TODO: Monster may be immune to: // - onfire (if is_immune_damage DT_HEAT, made_of LIQUID, has_flag MF_FIREY) // - stunned (if has_flag MF_STUN_IMMUNE) - WHEN( "monster is made of flesh and is warm-blooded" ) { - // Regular zombie - fleshy and warm - monster zed( mtype_id( "mon_zombie" ) ); - zed.clear_effects(); - REQUIRE( zed.made_of( material_id( "flesh" ) ) ); - REQUIRE( zed.has_flag( MF_WARM ) ); + WHEN( "monster is made of flesh and is not zombified" ) { + // Cow - fleshy and alive + monster cow( mtype_id( "mon_cow" ) ); + cow.clear_effects(); + REQUIRE( cow.made_of_any( Creature::cmat_flesh ) ); + REQUIRE_FALSE( cow.type->in_species( species_ZOMBIE ) ); THEN( "they can bleed" ) { - CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); + CHECK_FALSE( cow.is_immune_effect( effect_bleed ) ); } THEN( "they can be poisoned" ) { - CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); - CHECK_FALSE( zed.is_immune_effect( effect_poison ) ); - CHECK_FALSE( zed.is_immune_effect( effect_badpoison ) ); - CHECK_FALSE( zed.is_immune_effect( effect_paralyzepoison ) ); + CHECK_FALSE( cow.is_immune_effect( effect_poison ) ); + CHECK_FALSE( cow.is_immune_effect( effect_badpoison ) ); + CHECK_FALSE( cow.is_immune_effect( effect_paralyzepoison ) ); + CHECK_FALSE( cow.is_immune_effect( effect_venom_dmg ) ); + CHECK_FALSE( cow.is_immune_effect( effect_venom_weaken ) ); } - } - WHEN( "monster is not not made of flesh and not warm-blooded" ) { - // Skeleton - no flesh, not warm-blooded - monster skelly( mtype_id( "mon_skeleton" ) ); - skelly.clear_effects(); - REQUIRE_FALSE( skelly.made_of( material_id( "flesh" ) ) ); - REQUIRE_FALSE( skelly.made_of( material_id( "iflesh" ) ) ); - REQUIRE_FALSE( skelly.has_flag( MF_WARM ) ); + } + WHEN( "monster is made of flesh but is zombified" ) { + // Zombie - fleshy zombie + monster zed( mtype_id( "mon_zombie" ) ); + zed.clear_effects(); + REQUIRE( zed.made_of_any( Creature::cmat_flesh ) ); + REQUIRE( zed.type->in_species( species_ZOMBIE ) ); - THEN( "they are immune to the bleed effect" ) { - CHECK( skelly.is_immune_effect( effect_bleed ) ); + THEN( "they can bleed" ) { + CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); } - - THEN( "they are immune to all poison effects" ) { - CHECK( skelly.is_immune_effect( effect_bleed ) ); - CHECK( skelly.is_immune_effect( effect_poison ) ); - CHECK( skelly.is_immune_effect( effect_badpoison ) ); - CHECK( skelly.is_immune_effect( effect_paralyzepoison ) ); + THEN( "they can't be poisoned" ) { + CHECK( zed.is_immune_effect( effect_poison ) ); + CHECK( zed.is_immune_effect( effect_badpoison ) ); + CHECK( zed.is_immune_effect( effect_paralyzepoison ) ); + CHECK( zed.is_immune_effect( effect_venom_dmg ) ); + CHECK( zed.is_immune_effect( effect_venom_weaken ) ); } } - WHEN( "monster is made of flesh, but not warm-blooded" ) { + WHEN( "monster is made of flesh, but shouldn't bleed yet" ) { // Razorclaw - fleshy, with arthropod blood monster razorclaw( mtype_id( "mon_razorclaw" ) ); razorclaw.clear_effects(); @@ -406,11 +410,33 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) CHECK( razorclaw.is_immune_effect( effect_bleed ) ); } - THEN( "they are immune to all poison effects" ) { - CHECK( razorclaw.is_immune_effect( effect_bleed ) ); - CHECK( razorclaw.is_immune_effect( effect_poison ) ); - CHECK( razorclaw.is_immune_effect( effect_badpoison ) ); - CHECK( razorclaw.is_immune_effect( effect_paralyzepoison ) ); + THEN( "they can be poisoned" ) { + CHECK_FALSE( razorclaw.is_immune_effect( effect_poison ) ); + CHECK_FALSE( razorclaw.is_immune_effect( effect_badpoison ) ); + CHECK_FALSE( razorclaw.is_immune_effect( effect_paralyzepoison ) ); + CHECK_FALSE( razorclaw.is_immune_effect( effect_venom_dmg ) ); + CHECK_FALSE( razorclaw.is_immune_effect( effect_venom_weaken ) ); + } + } + + WHEN( "monster is not made of flesh or iflesh" ) { + // Fungaloid - veggy + monster fungaloid( mtype_id( "mon_fungaloid" ) ); + fungaloid.clear_effects(); + REQUIRE_FALSE( fungaloid.made_of( material_id( "flesh" ) ) ); + REQUIRE_FALSE( fungaloid.made_of( material_id( "iflesh" ) ) ); + REQUIRE_FALSE( fungaloid.has_flag( MF_WARM ) ); + + THEN( "they are immune to the bleed effect" ) { + CHECK( fungaloid.is_immune_effect( effect_bleed ) ); + } + + THEN( "they can't be poisoned" ) { + CHECK( fungaloid.is_immune_effect( effect_poison ) ); + CHECK( fungaloid.is_immune_effect( effect_badpoison ) ); + CHECK( fungaloid.is_immune_effect( effect_paralyzepoison ) ); + CHECK( fungaloid.is_immune_effect( effect_venom_dmg ) ); + CHECK( fungaloid.is_immune_effect( effect_venom_weaken ) ); } } } From 7de9f8321797ec7391684cddf97490fd0def7a5f Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 19 Dec 2020 21:44:52 +0100 Subject: [PATCH 02/23] Bleed --- src/monster.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index fe3adf868abe5..08b6f97391227 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1285,8 +1285,7 @@ bool monster::is_immune_effect( const efftype_id &effect ) const } if( effect == effect_bleed ) { - return !has_flag( MF_WARM ) || - !made_of( material_id( "flesh" ) ); + return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } if( effect == effect_paralyzepoison || From 8943e0f70a374949ed7f135099961778ebecba0a Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 19 Dec 2020 22:16:52 +0100 Subject: [PATCH 03/23] Damaging venom --- src/monster.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/monster.cpp b/src/monster.cpp index 08b6f97391227..dcc2a1f9b38e7 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1287,10 +1287,13 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_bleed ) { return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } + + if( effect == effect_venom_dmg ) { + return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); + } if( effect == effect_paralyzepoison || effect == effect_badpoison || - effect == effect_venom_dmg || effect == effect_venom_weaken || effect == effect_poison ) { return type->in_species( species_ZOMBIE ) || From 57f97cf0caff66a1e9a860b8d8fb6a42d7024c91 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 19 Dec 2020 22:26:09 +0100 Subject: [PATCH 04/23] Astyle --- src/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monster.cpp b/src/monster.cpp index dcc2a1f9b38e7..a6cc3b21b19f4 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1287,7 +1287,7 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_bleed ) { return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } - + if( effect == effect_venom_dmg ) { return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } From 7586da0545c8dbcf5ad76e2a1ba9abcf133cca0f Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Mon, 21 Dec 2020 19:44:24 +0100 Subject: [PATCH 05/23] Player venom iteration1 --- data/json/effects.json | 23 +++++++++++++++++++++++ src/melee.cpp | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/data/json/effects.json b/data/json/effects.json index 3f7745e371da8..3a9bdde2d4316 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -244,6 +244,29 @@ "name": [ "Pushed" ], "desc": [ "AI tag used for monsters pushing each other. This is a bug if you have it." ] }, + { + "type": "effect_type", + "id": "venom_player1", + "name": [ "Weak Player Venom" ], + "desc": [ "Don't worry, you shouldn't get this." ], + "max_duration": 120, + "base_mods": { "hurt_amount": [ 10 ], "hurt_min": [ 1 ], "hurt_chance": [ 2 ] }, + "//": "10+0,5/s dmg, from max duration avg 70 (range 10-130)" + }, + { + "type": "effect_type", + "id": "venom_player2", + "name": [ "Strong Player Venom" ], + "desc": [ "Don't worry, you reeally shouldn't get this." ], + "max_duration": 120, + "base_mods": { + "hurt_amount": [ 20 ], + "hurt_min": [ 4 ], + "hurt_chance": [ 2 ], + "speed_mod": [ -50 ] + }, + "//": "20+2/s dmg, from max duration avg 260 (range 20-480)" + }, { "//": "ACTUAL PLAYER EFFECTS START HERE", "type": "effect_type", diff --git a/src/melee.cpp b/src/melee.cpp index 30f5c55bbf6ee..90aa8d27f132f 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -91,6 +91,8 @@ static const efftype_id effect_lightsnare( "lightsnare" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_poison( "poison" ); static const efftype_id effect_stunned( "stunned" ); +static const efftype_id effect_venom_player1( "venom_player1" ); +static const efftype_id effect_venom_player2( "venom_player2" ); static const trait_id trait_ARM_TENTACLES( "ARM_TENTACLES" ); static const trait_id trait_ARM_TENTACLES_4( "ARM_TENTACLES_4" ); @@ -643,11 +645,11 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f dealt_dam.type_damage( damage_type::STAB ) > 0 ) ) ) { if( has_trait( trait_POISONOUS ) ) { add_msg_if_player( m_good, _( "You poison %s!" ), t.disp_name() ); - t.add_effect( effect_poison, 6_turns ); + t.add_effect( effect_venom_player1, 1_minutes ); } else if( has_trait( trait_POISONOUS2 ) ) { add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); - t.add_effect( effect_badpoison, 6_turns ); + t.add_effect( effect_venom_player2, 1_minutes ); } } From 56e70c85c10713799f985ec0bbabcab624296815 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Mon, 21 Dec 2020 22:22:19 +0100 Subject: [PATCH 06/23] Player alternative --- src/melee.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 90aa8d27f132f..f67dd5221b581 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -91,6 +91,8 @@ static const efftype_id effect_lightsnare( "lightsnare" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_poison( "poison" ); static const efftype_id effect_stunned( "stunned" ); +static const efftype_id effect_venom_dmg( "venom_dmg" ); +static const efftype_id effect_venom_weaken( "venom_weaken" ); static const efftype_id effect_venom_player1( "venom_player1" ); static const efftype_id effect_venom_player2( "venom_player2" ); @@ -645,11 +647,22 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f dealt_dam.type_damage( damage_type::STAB ) > 0 ) ) ) { if( has_trait( trait_POISONOUS ) ) { add_msg_if_player( m_good, _( "You poison %s!" ), t.disp_name() ); - t.add_effect( effect_venom_player1, 1_minutes ); + if( t.is_monster() ) { + t.add_effect( effect_venom_player1, 1_minutes ); + } else { + t.add_effect( effect_venom_dmg, 10_minutes ); + t.add_effect( effect_stunned, 1_turns ); + } } else if( has_trait( trait_POISONOUS2 ) ) { add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); - t.add_effect( effect_venom_player2, 1_minutes ); + if( t.is_monster() ) { + t.add_effect( effect_venom_player2, 1_minutes ); + t.add_effect( effect_stunned, 2_turns ); + } else { + t.add_effect( effect_venom_dmg, 15_minutes ); + t.add_effect( effect_venom_weaken, 5_minutes ); + } } } From a357a95cd94f6a665ed11eca22bf1d2f962c8bd9 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:11:10 +0100 Subject: [PATCH 07/23] Additional effects random --- src/melee.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index f67dd5221b581..51198932c259a 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -647,18 +647,22 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f dealt_dam.type_damage( damage_type::STAB ) > 0 ) ) ) { if( has_trait( trait_POISONOUS ) ) { add_msg_if_player( m_good, _( "You poison %s!" ), t.disp_name() ); + if( x_in_y( 1, 5 ) ) { + t.add_effect( effect_stunned, 1_turns ); + } if( t.is_monster() ) { t.add_effect( effect_venom_player1, 1_minutes ); } else { t.add_effect( effect_venom_dmg, 10_minutes ); - t.add_effect( effect_stunned, 1_turns ); } } else if( has_trait( trait_POISONOUS2 ) ) { add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); + if( x_in_y( 1, 5 ) ) { + t.add_effect( effect_downed, 1_turns ); + } if( t.is_monster() ) { t.add_effect( effect_venom_player2, 1_minutes ); - t.add_effect( effect_stunned, 2_turns ); } else { t.add_effect( effect_venom_dmg, 15_minutes ); t.add_effect( effect_venom_weaken, 5_minutes ); From 910f11594d9db2292266ac1ae2069e1e2bd682cf Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:11:49 +0100 Subject: [PATCH 08/23] Testt --- tests/creature_effect_test.cpp | 50 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index 86666dd6898a5..cfaadc745df10 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -83,8 +83,8 @@ TEST_CASE( "character add_effect", "[creature][character][effect][add]" ) TEST_CASE( "monster add_effect", "[creature][monster][effect][add]" ) { monster mummy( mtype_id( "debug_mon" ) ); - const efftype_id effect_bleed( "bleed" ); const efftype_id effect_grabbed( "grabbed" ); + const efftype_id effect_poison( "poison" ); mummy.clear_effects(); @@ -98,21 +98,21 @@ TEST_CASE( "monster add_effect", "[creature][monster][effect][add]" ) } } - // Debug monster is "flesh", but doesn't have the "WARM" flag, so is immune to bleeding. + // Debug monster is "flesh", but is zombified so can't be easily poisoned GIVEN( "monster is immune to effect" ) { - REQUIRE( mummy.is_immune_effect( effect_bleed ) ); + REQUIRE( mummy.is_immune_effect( effect_poison ) ); THEN( "monster add_effect is called with force = false" ) { - mummy.add_effect( effect_bleed, 1_minutes, false, 1, false ); + mummy.add_effect( effect_poison, 1_minutes, false, 1, false ); THEN( "they do not have the effect" ) { - CHECK_FALSE( mummy.has_effect( effect_bleed ) ); + CHECK_FALSE( mummy.has_effect( effect_poison ) ); } } WHEN( "monster add_effect is called with force = true" ) { - mummy.add_effect( effect_bleed, 1_minutes, false, 1, true ); + mummy.add_effect( effect_poison, 1_minutes, false, 1, true ); THEN( "they have the effect" ) { - CHECK( mummy.has_effect( effect_bleed ) ); + CHECK( mummy.has_effect( effect_poison ) ); } } } @@ -355,6 +355,8 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) const efftype_id effect_badpoison( "badpoison" ); const efftype_id effect_paralyzepoison( "paralyzepoison" ); const efftype_id effect_venom_dmg( "venom_dmg" ); + const efftype_id effect_venom_player1( "venom_player1" ); + const efftype_id effect_venom_player2( "venom_player2" ); const efftype_id effect_venom_weaken( "venom_weaken" ); // TODO: Monster may be immune to: @@ -371,11 +373,13 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) THEN( "they can bleed" ) { CHECK_FALSE( cow.is_immune_effect( effect_bleed ) ); } - THEN( "they can be poisoned" ) { + THEN( "they can be poisoned by all poisons" ) { CHECK_FALSE( cow.is_immune_effect( effect_poison ) ); CHECK_FALSE( cow.is_immune_effect( effect_badpoison ) ); CHECK_FALSE( cow.is_immune_effect( effect_paralyzepoison ) ); CHECK_FALSE( cow.is_immune_effect( effect_venom_dmg ) ); + CHECK_FALSE( cow.is_immune_effect( effect_venom_player1 ) ); + CHECK_FALSE( cow.is_immune_effect( effect_venom_player2 ) ); CHECK_FALSE( cow.is_immune_effect( effect_venom_weaken ) ); } @@ -390,35 +394,19 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) THEN( "they can bleed" ) { CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); } - THEN( "they can't be poisoned" ) { + THEN( "they can be poisoned by stronger poisons" ) { + CHECK_FALSE( zed.is_immune_effect( effect_venom_dmg ) ); + CHECK_FALSE( zed.is_immune_effect( effect_venom_player1 ) ); + CHECK_FALSE( zed.is_immune_effect( effect_venom_player2 ) ); + } + THEN( "they can't be poisoned by weaker poisons" ) { CHECK( zed.is_immune_effect( effect_poison ) ); CHECK( zed.is_immune_effect( effect_badpoison ) ); CHECK( zed.is_immune_effect( effect_paralyzepoison ) ); - CHECK( zed.is_immune_effect( effect_venom_dmg ) ); CHECK( zed.is_immune_effect( effect_venom_weaken ) ); } } - WHEN( "monster is made of flesh, but shouldn't bleed yet" ) { - // Razorclaw - fleshy, with arthropod blood - monster razorclaw( mtype_id( "mon_razorclaw" ) ); - razorclaw.clear_effects(); - REQUIRE( razorclaw.made_of( material_id( "flesh" ) ) ); - REQUIRE_FALSE( razorclaw.has_flag( MF_WARM ) ); - - THEN( "they are immune to the bleed effect" ) { - CHECK( razorclaw.is_immune_effect( effect_bleed ) ); - } - - THEN( "they can be poisoned" ) { - CHECK_FALSE( razorclaw.is_immune_effect( effect_poison ) ); - CHECK_FALSE( razorclaw.is_immune_effect( effect_badpoison ) ); - CHECK_FALSE( razorclaw.is_immune_effect( effect_paralyzepoison ) ); - CHECK_FALSE( razorclaw.is_immune_effect( effect_venom_dmg ) ); - CHECK_FALSE( razorclaw.is_immune_effect( effect_venom_weaken ) ); - } - } - WHEN( "monster is not made of flesh or iflesh" ) { // Fungaloid - veggy monster fungaloid( mtype_id( "mon_fungaloid" ) ); @@ -436,6 +424,8 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) CHECK( fungaloid.is_immune_effect( effect_badpoison ) ); CHECK( fungaloid.is_immune_effect( effect_paralyzepoison ) ); CHECK( fungaloid.is_immune_effect( effect_venom_dmg ) ); + CHECK( fungaloid.is_immune_effect( effect_venom_player1 ) ); + CHECK( fungaloid.is_immune_effect( effect_venom_player2 ) ); CHECK( fungaloid.is_immune_effect( effect_venom_weaken ) ); } } From 0cf9ce53dccccb67344a31a3a4d130a345ab358e Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Tue, 22 Dec 2020 20:47:49 +0100 Subject: [PATCH 09/23] Damaging venom zed --- src/monster.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index a6cc3b21b19f4..7628d00553e38 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -89,6 +89,8 @@ static const efftype_id effect_stunned( "stunned" ); static const efftype_id effect_supercharged( "supercharged" ); static const efftype_id effect_tied( "tied" ); static const efftype_id effect_venom_dmg( "venom_dmg" ); +static const efftype_id effect_venom_player1( "venom_player1" ); +static const efftype_id effect_venom_player2( "venom_player2" ); static const efftype_id effect_venom_weaken( "venom_weaken" ); static const efftype_id effect_webbed( "webbed" ); @@ -1288,14 +1290,16 @@ bool monster::is_immune_effect( const efftype_id &effect ) const return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } - if( effect == effect_venom_dmg ) { + if( effect == effect_venom_dmg || + effect == effect_venom_player1 || + effect == effect_venom_player2) { return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); } if( effect == effect_paralyzepoison || effect == effect_badpoison || effect == effect_venom_weaken || - effect == effect_poison ) { + effect == effect_poison ) { return type->in_species( species_ZOMBIE ) || !made_of_any( Creature::cmat_flesh ); } From d628fb7a6bf175ee0bdac58d7f1d244f68e42b10 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Tue, 22 Dec 2020 22:29:45 +0100 Subject: [PATCH 10/23] Nether+Test --- src/monster.cpp | 13 ++++++++----- tests/creature_effect_test.cpp | 24 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index 7628d00553e38..7b6c75f81e3e1 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -101,8 +101,10 @@ static const itype_id itype_milk_raw( "milk_raw" ); static const species_id species_FISH( "FISH" ); static const species_id species_FUNGUS( "FUNGUS" ); static const species_id species_INSECT( "INSECT" ); +static const species_id species_LEECH_PLANT( "LEECH_PLANT" ); static const species_id species_MAMMAL( "MAMMAL" ); static const species_id species_MOLLUSK( "MOLLUSK" ); +static const species_id species_NETHER( "NETHER" ); static const species_id species_ROBOT( "ROBOT" ); static const species_id species_SPIDER( "SPIDER" ); static const species_id species_ZOMBIE( "ZOMBIE" ); @@ -1292,16 +1294,17 @@ bool monster::is_immune_effect( const efftype_id &effect ) const if( effect == effect_venom_dmg || effect == effect_venom_player1 || - effect == effect_venom_player2) { - return !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ); + effect == effect_venom_player2 ) { + return ( !made_of( material_id( "flesh" ) ) && !made_of( material_id( "iflesh" ) ) ) || + type->in_species( species_NETHER ) || type->in_species( species_LEECH_PLANT ); } if( effect == effect_paralyzepoison || effect == effect_badpoison || effect == effect_venom_weaken || - effect == effect_poison ) { - return type->in_species( species_ZOMBIE ) || - !made_of_any( Creature::cmat_flesh ); + effect == effect_poison ) { + return type->in_species( species_ZOMBIE ) || type->in_species( species_NETHER ) || + !made_of_any( Creature::cmat_flesh ) || type->in_species( species_LEECH_PLANT ); } if( effect == effect_stunned ) { diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index cfaadc745df10..3eb2ae5611b20 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -8,6 +8,7 @@ #include "mtype.h" #include "type_id.h" +static const species_id species_NETHER( "NETHER" ); static const species_id species_ZOMBIE( "ZOMBIE" ); // Test effect methods from `Creature` class on both `monster` and `player` @@ -407,13 +408,34 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) } } + WHEN( "monster is not made of flesh, but it's weird nether stuff" ) { + // Mi-Go, flesh but Nether species + monster migo( mtype_id( "mon_mi_go" ) ); + migo.clear_effects(); + REQUIRE( migo.made_of( material_id( "flesh" ) ) ); + REQUIRE_FALSE( migo.made_of( material_id( "iflesh" ) ) ); + REQUIRE( migo.type->in_species( species_NETHER ) ); + + THEN( "they can still bleed" ) { + CHECK_FALSE( migo.is_immune_effect( effect_bleed ) ); + } + + THEN( "they can't be poisoned" ) { + CHECK( migo.is_immune_effect( effect_poison ) ); + CHECK( migo.is_immune_effect( effect_badpoison ) ); + CHECK( migo.is_immune_effect( effect_paralyzepoison ) ); + CHECK( migo.is_immune_effect( effect_venom_dmg ) ); + CHECK( migo.is_immune_effect( effect_venom_player1 ) ); + CHECK( migo.is_immune_effect( effect_venom_player2 ) ); + CHECK( migo.is_immune_effect( effect_venom_weaken ) ); + } + } WHEN( "monster is not made of flesh or iflesh" ) { // Fungaloid - veggy monster fungaloid( mtype_id( "mon_fungaloid" ) ); fungaloid.clear_effects(); REQUIRE_FALSE( fungaloid.made_of( material_id( "flesh" ) ) ); REQUIRE_FALSE( fungaloid.made_of( material_id( "iflesh" ) ) ); - REQUIRE_FALSE( fungaloid.has_flag( MF_WARM ) ); THEN( "they are immune to the bleed effect" ) { CHECK( fungaloid.is_immune_effect( effect_bleed ) ); From d263aa84b5475b3852a24ac8fcc492a571f017fb Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Tue, 22 Dec 2020 22:34:14 +0100 Subject: [PATCH 11/23] Lint --- data/json/effects.json | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/data/json/effects.json b/data/json/effects.json index 3a9bdde2d4316..6adde32955d1b 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -246,26 +246,21 @@ }, { "type": "effect_type", - "id": "venom_player1", - "name": [ "Weak Player Venom" ], - "desc": [ "Don't worry, you shouldn't get this." ], - "max_duration": 120, - "base_mods": { "hurt_amount": [ 10 ], "hurt_min": [ 1 ], "hurt_chance": [ 2 ] }, - "//": "10+0,5/s dmg, from max duration avg 70 (range 10-130)" - }, - { - "type": "effect_type", - "id": "venom_player2", - "name": [ "Strong Player Venom" ], - "desc": [ "Don't worry, you reeally shouldn't get this." ], - "max_duration": 120, - "base_mods": { - "hurt_amount": [ 20 ], - "hurt_min": [ 4 ], - "hurt_chance": [ 2 ], - "speed_mod": [ -50 ] - }, - "//": "20+2/s dmg, from max duration avg 260 (range 20-480)" + "id": "venom_player1", + "name": [ "Weak Player Venom" ], + "desc": [ "Don't worry, you shouldn't get this." ], + "max_duration": 120, + "base_mods": { "hurt_amount": [ 10 ], "hurt_min": [ 1 ], "hurt_chance": [ 2 ] }, + "//": "10+0,5/s dmg, from max duration avg 70 (range 10-130)" + }, + { + "type": "effect_type", + "id": "venom_player2", + "name": [ "Strong Player Venom" ], + "desc": [ "Don't worry, you reeally shouldn't get this." ], + "max_duration": 120, + "base_mods": { "hurt_amount": [ 20 ], "hurt_min": [ 4 ], "hurt_chance": [ 2 ], "speed_mod": [ -50 ] }, + "//": "20+2/s dmg, from max duration avg 260 (range 20-480)" }, { "//": "ACTUAL PLAYER EFFECTS START HERE", From 58322978f7164ec2db290a862f38d6fd8934faaf Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Thu, 24 Dec 2020 21:46:45 +0100 Subject: [PATCH 12/23] Typo --- data/json/effects.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/effects.json b/data/json/effects.json index 6adde32955d1b..151935040dfa1 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -257,7 +257,7 @@ "type": "effect_type", "id": "venom_player2", "name": [ "Strong Player Venom" ], - "desc": [ "Don't worry, you reeally shouldn't get this." ], + "desc": [ "Don't worry, you really shouldn't get this." ], "max_duration": 120, "base_mods": { "hurt_amount": [ 20 ], "hurt_min": [ 4 ], "hurt_chance": [ 2 ], "speed_mod": [ -50 ] }, "//": "20+2/s dmg, from max duration avg 260 (range 20-480)" From 9568e3064b5d47b0f2d395c5a4c79a9a3e7e47ff Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Thu, 24 Dec 2020 21:48:12 +0100 Subject: [PATCH 13/23] Downed --- src/monster.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/monster.cpp b/src/monster.cpp index 7b6c75f81e3e1..5bbce8d9cc42e 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1311,6 +1311,12 @@ bool monster::is_immune_effect( const efftype_id &effect ) const return has_flag( MF_STUN_IMMUNE ); } + if( effect == effect_downed ) { + if( type->bodytype == "insect" || type->bodytype == "spider" || type->bodytype == "crab" ) { + return x_in_y( 3, 4 ); + } else return type->bodytype == "snake" || type->bodytype == "blob" || type->bodytype == "fish" || + has_flag( MF_FLIES ); + } return false; } From f2b906d8e6c9435e1d41b98b0e11d02b8c75fdba Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Thu, 24 Dec 2020 22:46:16 +0100 Subject: [PATCH 14/23] Downed test --- tests/creature_effect_test.cpp | 73 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index 3eb2ae5611b20..f0dbc223ba790 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -354,6 +354,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) const efftype_id effect_bleed( "bleed" ); const efftype_id effect_poison( "poison" ); const efftype_id effect_badpoison( "badpoison" ); + const efftype_id effect_downed( "downed" ); const efftype_id effect_paralyzepoison( "paralyzepoison" ); const efftype_id effect_venom_dmg( "venom_dmg" ); const efftype_id effect_venom_player1( "venom_player1" ); @@ -365,69 +366,85 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) // - stunned (if has_flag MF_STUN_IMMUNE) WHEN( "monster is made of flesh and is not zombified" ) { - // Cow - fleshy and alive - monster cow( mtype_id( "mon_cow" ) ); - cow.clear_effects(); - REQUIRE( cow.made_of_any( Creature::cmat_flesh ) ); - REQUIRE_FALSE( cow.type->in_species( species_ZOMBIE ) ); + // snek - fleshy, living snake + monster snek( mtype_id( "mon_rattlesnake" ) ); + snek.clear_effects(); + REQUIRE( snek.made_of_any( Creature::cmat_flesh ) ); + REQUIRE_FALSE( snek.type->in_species( species_ZOMBIE ) ); + REQUIRE( snek.type->bodytype == "snake" ); THEN( "they can bleed" ) { - CHECK_FALSE( cow.is_immune_effect( effect_bleed ) ); + CHECK_FALSE( snek.is_immune_effect( effect_bleed ) ); } THEN( "they can be poisoned by all poisons" ) { - CHECK_FALSE( cow.is_immune_effect( effect_poison ) ); - CHECK_FALSE( cow.is_immune_effect( effect_badpoison ) ); - CHECK_FALSE( cow.is_immune_effect( effect_paralyzepoison ) ); - CHECK_FALSE( cow.is_immune_effect( effect_venom_dmg ) ); - CHECK_FALSE( cow.is_immune_effect( effect_venom_player1 ) ); - CHECK_FALSE( cow.is_immune_effect( effect_venom_player2 ) ); - CHECK_FALSE( cow.is_immune_effect( effect_venom_weaken ) ); + CHECK_FALSE( snek.is_immune_effect( effect_poison ) ); + CHECK_FALSE( snek.is_immune_effect( effect_badpoison ) ); + CHECK_FALSE( snek.is_immune_effect( effect_paralyzepoison ) ); + CHECK_FALSE( snek.is_immune_effect( effect_venom_dmg ) ); + CHECK_FALSE( snek.is_immune_effect( effect_venom_player1 ) ); + CHECK_FALSE( snek.is_immune_effect( effect_venom_player2 ) ); + CHECK_FALSE( snek.is_immune_effect( effect_venom_weaken ) ); + } + + THEN( "they can't be downed" ) { + CHECK( snek.is_immune_effect( effect_downed ) ); } } WHEN( "monster is made of flesh but is zombified" ) { - // Zombie - fleshy zombie + // Zombie - fleshy humanoid zombie monster zed( mtype_id( "mon_zombie" ) ); zed.clear_effects(); REQUIRE( zed.made_of_any( Creature::cmat_flesh ) ); REQUIRE( zed.type->in_species( species_ZOMBIE ) ); + REQUIRE( zed.type->bodytype == "human" ); THEN( "they can bleed" ) { CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); } + THEN( "they can be poisoned by stronger poisons" ) { CHECK_FALSE( zed.is_immune_effect( effect_venom_dmg ) ); CHECK_FALSE( zed.is_immune_effect( effect_venom_player1 ) ); CHECK_FALSE( zed.is_immune_effect( effect_venom_player2 ) ); } + THEN( "they can't be poisoned by weaker poisons" ) { CHECK( zed.is_immune_effect( effect_poison ) ); CHECK( zed.is_immune_effect( effect_badpoison ) ); CHECK( zed.is_immune_effect( effect_paralyzepoison ) ); CHECK( zed.is_immune_effect( effect_venom_weaken ) ); } + + THEN( "they can be downed" ) { + CHECK_FALSE( zed.is_immune_effect( effect_downed ) ); + } } WHEN( "monster is not made of flesh, but it's weird nether stuff" ) { - // Mi-Go, flesh but Nether species - monster migo( mtype_id( "mon_mi_go" ) ); - migo.clear_effects(); - REQUIRE( migo.made_of( material_id( "flesh" ) ) ); - REQUIRE_FALSE( migo.made_of( material_id( "iflesh" ) ) ); - REQUIRE( migo.type->in_species( species_NETHER ) ); + // Flaming eye, flesh but Nether species and flying + monster feye( mtype_id( "mon_flaming_eye" ) ); + feye.clear_effects(); + REQUIRE( feye.made_of( material_id( "flesh" ) ) ); + REQUIRE( feye.has_flag( MF_FLIES ) ); + REQUIRE( feye.type->in_species( species_NETHER ) ); THEN( "they can still bleed" ) { - CHECK_FALSE( migo.is_immune_effect( effect_bleed ) ); + CHECK_FALSE( feye.is_immune_effect( effect_bleed ) ); } THEN( "they can't be poisoned" ) { - CHECK( migo.is_immune_effect( effect_poison ) ); - CHECK( migo.is_immune_effect( effect_badpoison ) ); - CHECK( migo.is_immune_effect( effect_paralyzepoison ) ); - CHECK( migo.is_immune_effect( effect_venom_dmg ) ); - CHECK( migo.is_immune_effect( effect_venom_player1 ) ); - CHECK( migo.is_immune_effect( effect_venom_player2 ) ); - CHECK( migo.is_immune_effect( effect_venom_weaken ) ); + CHECK( feye.is_immune_effect( effect_poison ) ); + CHECK( feye.is_immune_effect( effect_badpoison ) ); + CHECK( feye.is_immune_effect( effect_paralyzepoison ) ); + CHECK( feye.is_immune_effect( effect_venom_dmg ) ); + CHECK( feye.is_immune_effect( effect_venom_player1 ) ); + CHECK( feye.is_immune_effect( effect_venom_player2 ) ); + CHECK( feye.is_immune_effect( effect_venom_weaken ) ); + } + + THEN( "they can't be downed" ) { + CHECK( feye.is_immune_effect( effect_downed ) ); } } WHEN( "monster is not made of flesh or iflesh" ) { From eb1a0c86822cec363b7c1b776773851052985c95 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Fri, 25 Dec 2020 11:12:22 +0100 Subject: [PATCH 15/23] Whoops! Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com> --- src/monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monster.cpp b/src/monster.cpp index 49fe1039b87ab..e5ca8aed0e9cc 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -117,7 +117,7 @@ static const trait_id trait_FLOWERS( "FLOWERS" ); static const trait_id trait_KILLER( "KILLER" ); static const trait_id trait_MYCUS_FRIEND( "MYCUS_FRIEND" ); static const trait_id trait_PACIFIST( "PACIFIST" ); -static const trait_id trait_PHEROMONE_( "PHEROMONE_INSECT" ); +static const trait_id trait_PHEROMONE_INSECT( "PHEROMONE_INSECT" ); static const trait_id trait_PHEROMONE_MAMMAL( "PHEROMONE_MAMMAL" ); static const trait_id trait_TERRIFYING( "TERRIFYING" ); static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); From 7be91dc009761d20953c2a4cb45a9b43f040dde1 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Mon, 28 Dec 2020 15:01:24 +0100 Subject: [PATCH 16/23] Message, balance --- src/melee.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 51198932c259a..6a65810b7f7d5 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -646,26 +646,33 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f ( cur_weapon && cur_weapon->is_null() && ( dealt_dam.type_damage( damage_type::CUT ) > 0 || dealt_dam.type_damage( damage_type::STAB ) > 0 ) ) ) { if( has_trait( trait_POISONOUS ) ) { - add_msg_if_player( m_good, _( "You poison %s!" ), t.disp_name() ); - if( x_in_y( 1, 5 ) ) { - t.add_effect( effect_stunned, 1_turns ); - } if( t.is_monster() ) { t.add_effect( effect_venom_player1, 1_minutes ); } else { t.add_effect( effect_venom_dmg, 10_minutes ); } - } else if( has_trait( trait_POISONOUS2 ) ) { - add_msg_if_player( m_good, _( "You inject your venom into %s!" ), - t.disp_name() ); - if( x_in_y( 1, 5 ) ) { - t.add_effect( effect_downed, 1_turns ); - } - if( t.is_monster() ) { - t.add_effect( effect_venom_player2, 1_minutes ); + if( t.is_immune_effect( effect_venom_player1 ) ) { + add_msg_if_player( m_bad, _( "The %s is not affected by your venom" ), t.disp_name() ); } else { - t.add_effect( effect_venom_dmg, 15_minutes ); - t.add_effect( effect_venom_weaken, 5_minutes ); + add_msg_if_player( m_good, _( "You poison %s!" ), t.disp_name() ); + if( x_in_y( 1, 10 ) ) { + t.add_effect( effect_stunned, 1_turns ); + } + } + } else if( has_trait( trait_POISONOUS2 ) ) { + } + if( t.is_monster() ) { + t.add_effect( effect_venom_player2, 1_minutes ); + } else { + t.add_effect( effect_venom_dmg, 15_minutes ); + t.add_effect( effect_venom_weaken, 5_minutes ); + } + if( t.is_immune_effect( effect_venom_player2 ) ) { + add_msg_if_player( m_bad, _( "The %s is not affected by your venom" ), t.disp_name() ) ; + } else { + add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); + if( x_in_y( 1, 4 ) ) { + t.add_effect( effect_stunned, 1_turns ); } } } From d1c92daa32bdd928458a3b46744ec5f6f49e7de1 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Mon, 28 Dec 2020 19:57:07 +0100 Subject: [PATCH 17/23] Update melee.cpp --- src/melee.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 6a65810b7f7d5..7134539c1d56c 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -660,23 +660,22 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f } } } else if( has_trait( trait_POISONOUS2 ) ) { - } - if( t.is_monster() ) { - t.add_effect( effect_venom_player2, 1_minutes ); - } else { - t.add_effect( effect_venom_dmg, 15_minutes ); - t.add_effect( effect_venom_weaken, 5_minutes ); - } - if( t.is_immune_effect( effect_venom_player2 ) ) { - add_msg_if_player( m_bad, _( "The %s is not affected by your venom" ), t.disp_name() ) ; - } else { - add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); - if( x_in_y( 1, 4 ) ) { - t.add_effect( effect_stunned, 1_turns ); + if( t.is_monster() ) { + t.add_effect( effect_venom_player2, 1_minutes ); + } else { + t.add_effect( effect_venom_dmg, 15_minutes ); + t.add_effect( effect_venom_weaken, 5_minutes ); + } + if( t.is_immune_effect( effect_venom_player2 ) ) { + add_msg_if_player( m_bad, _( "The %s is not affected by your venom" ), t.disp_name() ); + } else { + add_msg_if_player( m_good, _( "You inject your venom into %s!" ), t.disp_name() ); + if( x_in_y( 1, 4 ) ) { + t.add_effect( effect_stunned, 1_turns ); + } } } } - // Make a rather quiet sound, to alert any nearby monsters if( !is_quiet() ) { // check martial arts silence //sound generated later From 0309a0bc96b35b6dd7b1ec35ad25d43f44b9208d Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Fri, 1 Jan 2021 20:48:39 +0100 Subject: [PATCH 18/23] Update creature_effect_test.cpp --- tests/creature_effect_test.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index 5494adc4b3210..566834c9f9843 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -362,6 +362,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) const efftype_id effect_venom_weaken( "venom_weaken" ); static const species_id species_WORM( "WORM" ); + static const species_id species_FUNGUS( "FUNGUS" ); // TODO: Monster may be immune to: // - onfire (if is_immune_damage DT_HEAT, made_of LIQUID, has_flag MF_FIREY) @@ -372,11 +373,12 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) monster graboid( mtype_id( "mon_graboid" ) ); graboid.clear_effects(); REQUIRE( graboid.made_of_any( Creature::cmat_flesh ) ); - REQUIRE( graboid.type->bodytype == "snake" ); - REQUIRE( graboid.type->in_species( species_WORM ) ); + REQUIRE( graboid.type->bodytype == "snake" ); + REQUIRE( graboid.type->in_species( species_WORM ) ); THEN( "they can bleed" ) { CHECK_FALSE( graboid.is_immune_effect( effect_bleed ) ); + } THEN( "they can be poisoned by all poisons" ) { CHECK_FALSE( graboid.is_immune_effect( effect_poison ) ); @@ -393,7 +395,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) } } - + WHEN( "monster is a zombie, made of flesh, has blood and has legs" ) { // Zombie - fleshy humanoid zombie monster zed( mtype_id( "mon_zombie" ) ); @@ -405,7 +407,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) THEN( "they can bleed" ) { CHECK_FALSE( zed.is_immune_effect( effect_bleed ) ); } - + THEN( "they can be poisoned by stronger poisons" ) { CHECK_FALSE( zed.is_immune_effect( effect_venom_dmg ) ); CHECK_FALSE( zed.is_immune_effect( effect_venom_player1 ) ); @@ -445,18 +447,18 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) CHECK( feye.is_immune_effect( effect_venom_player2 ) ); CHECK( feye.is_immune_effect( effect_venom_weaken ) ); } - - THEN( "they can't be downed" ) { + + THEN( "they can't be downed" ) { CHECK( feye.is_immune_effect( effect_downed ) ); } } - + WHEN( "monster is not made of flesh or iflesh" ) { // Fungaloid - veggy, has no blood or bodytype monster fungaloid( mtype_id( "mon_fungaloid" ) ); fungaloid.clear_effects(); REQUIRE_FALSE( fungaloid.made_of_any( Creature::cmat_flesh ) ); - REQUIRE( fungaloid.type->in_species( species_FUNGUS ) + REQUIRE( fungaloid.type->in_species( species_FUNGUS ) ); THEN( "they are immune to the bleed effect" ) { CHECK( fungaloid.is_immune_effect( effect_bleed ) ); @@ -470,12 +472,12 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) CHECK( fungaloid.is_immune_effect( effect_venom_player1 ) ); CHECK( fungaloid.is_immune_effect( effect_venom_player2 ) ); CHECK( fungaloid.is_immune_effect( effect_venom_weaken ) ); - } - - THEN( "they can be downed" ) { - CHECK_FALSE( fungaloid.is_immune_effect( effect_downed) ); - } - } + } + + THEN( "they can be downed" ) { + CHECK_FALSE( fungaloid.is_immune_effect( effect_downed ) ); + } + } WHEN( "monster species doesn't have bleeding type set, but it has flag describing its bleeding type" ) { // Razorclaw - has `MUTANT` species which doesn't have any bleeding type set, but has arthropod blood From 493318515b79a3a4c5614f00939f2480dc881878 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Fri, 1 Jan 2021 21:47:07 +0100 Subject: [PATCH 19/23] huh --- src/monster.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/monster.cpp b/src/monster.cpp index 27334ba00d1bd..6a22535947479 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1410,18 +1410,20 @@ void monster::melee_attack( Creature &target ) void monster::melee_attack( Creature &target, float accuracy ) { - int hitspread = target.deal_melee_attack( this, melee::melee_hit_range( accuracy ) ); + // Note: currently this method must consume move even if attack hasn't actually happen + // otherwise infinite loop will happen mod_moves( -type->attack_cost ); - if( type->melee_dice == 0 ) { - // We don't attack, so just return + if( /*This happens sometimes*/ this == &target || !is_adjacent( &target, true ) ) { return; } - if( this == &target ) { - // This happens sometimes + int hitspread = target.deal_melee_attack( this, melee::melee_hit_range( accuracy ) ); + if( type->melee_dice == 0 ) { + // We don't attack, so just return return; } + Character &player_character = get_player_character(); if( target.is_player() || ( target.is_npc() && player_character.attitude_to( target ) == Attitude::FRIENDLY ) ) { From e61e9f33fbe17099dbda8427864eb56e5c9a36f7 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Fri, 1 Jan 2021 21:48:05 +0100 Subject: [PATCH 20/23] Update monster.cpp --- src/monster.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/monster.cpp b/src/monster.cpp index 6a22535947479..0937064d66281 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -1423,7 +1423,6 @@ void monster::melee_attack( Creature &target, float accuracy ) return; } - Character &player_character = get_player_character(); if( target.is_player() || ( target.is_npc() && player_character.attitude_to( target ) == Attitude::FRIENDLY ) ) { From a7f027b38048d9037bd8d107e3eb1682dd7175b2 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 2 Jan 2021 08:34:46 +0100 Subject: [PATCH 21/23] Bleed test --- tests/creature_effect_test.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index 566834c9f9843..3d0397f19a8fc 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -393,7 +393,6 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) THEN( "they can't be downed" ) { CHECK( graboid.is_immune_effect( effect_downed ) ); } - } WHEN( "monster is a zombie, made of flesh, has blood and has legs" ) { @@ -426,7 +425,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) } } - WHEN( "monster is made of nether flesh, has no blood and is flying" ) { + WHEN( "monster is made of nether flesh and is flying" ) { // Flaming eye, flesh, Nether species and flying monster feye( mtype_id( "mon_flaming_eye" ) ); feye.clear_effects(); @@ -434,7 +433,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) REQUIRE( feye.has_flag( MF_FLIES ) ); REQUIRE( feye.type->in_species( species_NETHER ) ); - THEN( "they can't bleed" ) { + THEN( "they can bleed" ) { CHECK( feye.is_immune_effect( effect_bleed ) ); } @@ -460,8 +459,8 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) REQUIRE_FALSE( fungaloid.made_of_any( Creature::cmat_flesh ) ); REQUIRE( fungaloid.type->in_species( species_FUNGUS ) ); - THEN( "they are immune to the bleed effect" ) { - CHECK( fungaloid.is_immune_effect( effect_bleed ) ); + THEN( "they bleed plant sap for now" ) { + CHECK_FALSE( fungaloid.is_immune_effect( effect_bleed ) ); } THEN( "they can't be poisoned" ) { From f6f475a21d3995d6e2e73f7bf17938b5cb8f0f69 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Sat, 2 Jan 2021 09:02:31 +0100 Subject: [PATCH 22/23] Update creature_effect_test.cpp --- tests/creature_effect_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/creature_effect_test.cpp b/tests/creature_effect_test.cpp index 3d0397f19a8fc..ebdabee166658 100644 --- a/tests/creature_effect_test.cpp +++ b/tests/creature_effect_test.cpp @@ -434,7 +434,7 @@ TEST_CASE( "monster is_immune_effect", "[creature][monster][effect][immune]" ) REQUIRE( feye.type->in_species( species_NETHER ) ); THEN( "they can bleed" ) { - CHECK( feye.is_immune_effect( effect_bleed ) ); + CHECK_FALSE( feye.is_immune_effect( effect_bleed ) ); } THEN( "they can't be poisoned" ) { From 64df8063f04adad4a7ce34875c999073fc689610 Mon Sep 17 00:00:00 2001 From: Venera3 <72006894+Venera3@users.noreply.github.com> Date: Thu, 14 Jan 2021 20:23:21 +0100 Subject: [PATCH 23/23] Update effects.json --- data/json/effects.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/json/effects.json b/data/json/effects.json index af030db9dd4f2..b1bfc21e9996d 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -263,6 +263,7 @@ "//": "20+2/s dmg, from max duration avg 260 (range 20-480)" }, { + "type": "effect_type", "id": "dripping_mechanical_fluid", "name": [ "Mechanical fluid dripping" ], "desc": [ "AI tag used for robot monsters losing mechanical fluid. This is a bug if you have it." ],