Skip to content

Commit

Permalink
Merge pull request CleverRaven#75946 from GuardianDll/weakpoint_condi…
Browse files Browse the repository at this point in the history
…tions

Weakpoints can use conditions and eocs
  • Loading branch information
Maleclypse authored Aug 27, 2024
2 parents 9a42acb + aacf40b commit 4a935ad
Show file tree
Hide file tree
Showing 26 changed files with 119 additions and 92 deletions.
2 changes: 1 addition & 1 deletion data/json/monster_weakpoints/abomination_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"crit_mult": { "all": 1.2 },
"coverage": 15,
"coverage_mult": { "cut": 1.5 },
"required_effects": [ "maimed_armor" ]
"condition": { "npc_has_any_effect": [ "maimed_armor" ] }
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions data/json/monster_weakpoints/amphibian_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"coverage": 10,
"armor_mult": { "all": 0.9 },
"crit_mult": { "all": 1.25 },
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"effects": [
{
"effect": "maimed_mandible",
Expand Down Expand Up @@ -212,7 +212,7 @@
"coverage": 15,
"coverage_mult": { "point": 0.75 },
"crit_mult": { "all": 1.25 },
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"effects": [
{
"effect": "maimed_tongue",
Expand Down Expand Up @@ -416,7 +416,7 @@
"coverage": 10,
"armor_mult": { "all": 1.75 },
"crit_mult": { "all": 1.1 },
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"effects": [
{
"effect": "maimed_mandible",
Expand Down
4 changes: 2 additions & 2 deletions data/json/monster_weakpoints/arthropod_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
"armor_mult": { "physical": 0.2 },
"difficulty": { "ranged": 7, "melee": 2 },
"coverage_mult": { "point": 0.75 },
"required_effects": [ "staggered" ],
"condition": { "npc_has_any_effect": [ "staggered" ] },
"effects": [
{ "effect": "downed", "chance": 25, "message": "The %s is knocked down!", "damage_required": [ 1, 100 ] },
{
Expand Down Expand Up @@ -356,7 +356,7 @@
"armor_mult": { "all": 0.33 },
"crit_mult": { "all": 1.2 },
"coverage": 15,
"required_effects": [ "maimed_armor" ]
"condition": { "npc_has_any_effect": [ "maimed_armor" ] }
},
{
"id": "abdomen",
Expand Down
2 changes: 1 addition & 1 deletion data/json/monster_weakpoints/bird_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"difficulty": { "melee": 4, "ranged": 1 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
},
{
"name": "the eye",
Expand Down
2 changes: 1 addition & 1 deletion data/json/monster_weakpoints/cyborg_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"damage_required": [ 31, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down
10 changes: 5 additions & 5 deletions data/json/monster_weakpoints/humanoid_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"damage_required": [ 31, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down Expand Up @@ -286,7 +286,7 @@
"armor_mult": { "cut": 1.5, "stab": 1.5, "bash": 1.5 },
"coverage_mult": { "ranged": 0.8, "melee": 0 },
"//": "Note that most bullet hits on an armour plate probably shatter it, but not all of them shatter it enough to matter for future attacks.",
"disabled_by": [ "shattered" ],
"condition": { "not": { "npc_has_any_effect": [ "shattered" ] } },
"effects": [
{
"effect": "shattered",
Expand Down Expand Up @@ -318,7 +318,7 @@
"armor_mult": { "cut": 1.3, "stab": 1.15, "bash": 1.15 },
"coverage_mult": { "ranged": 0, "melee": 0.8 },
"//": "Note that most bullet hits on an armour plate probably shatter it, but not all of them shatter it enough to matter for future attacks.",
"disabled_by": [ "shattered" ],
"condition": { "not": { "npc_has_any_effect": [ "shattered" ] } },
"effects": [
{
"effect": "shattered",
Expand Down Expand Up @@ -351,7 +351,7 @@
"difficulty": { "broad": 3, "point": 2 },
"coverage_mult": { "ranged": 0.8 },
"coverage": 40,
"required_effects": [ "shattered" ]
"condition": { "npc_has_any_effect": [ "shattered" ] }
},
{
"id": "side_armour",
Expand Down Expand Up @@ -671,7 +671,7 @@
"damage_required": [ 31, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/json/monsters/misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"armor_penalty": { "bullet": 25 },
"coverage": 50,
"coverage_mult": { "all": 0.5 },
"required_effects": [ "stunned" ]
"condition": { "npc_has_any_effect": [ "stunned" ] }
},
{ "name": "impossible to hit", "coverage": 100, "difficulty": { "all": 100.0 } },
{
Expand Down
12 changes: 6 additions & 6 deletions data/mods/DinoMod/dinosaur_weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"difficulty": { "melee": 5, "ranged": 5 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ],
"condition": { "npc_has_any_effect": [ "downed" ] },
"effects": [
{
"effect": "stunned",
Expand All @@ -100,7 +100,7 @@
"difficulty": { "melee": 4, "ranged": 1 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
},
{
"name": "the eye",
Expand All @@ -109,7 +109,7 @@
"crit_mult": { "all": 1.25 },
"coverage_mult": { "ranged": 0.5 },
"difficulty": { "point": 10, "broad": 10 },
"required_effects": [ "downed" ],
"condition": { "npc_has_any_effect": [ "downed" ] },
"effects": [
{ "effect": "blind", "duration": [ 1, 2 ], "chance": 25, "message": "The %s is blinded!", "damage_required": [ 1, 25 ] },
{
Expand Down Expand Up @@ -230,7 +230,7 @@
"difficulty": { "melee": 4, "ranged": 1 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
},
{
"name": "the eye",
Expand Down Expand Up @@ -295,7 +295,7 @@
"difficulty": { "melee": 4, "ranged": 1 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
},
{
"name": "the eye",
Expand Down Expand Up @@ -360,7 +360,7 @@
"difficulty": { "melee": 4, "ranged": 1 },
"coverage_mult": { "ranged": 0.75 },
"coverage": 3,
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
},
{
"name": "the eye",
Expand Down
4 changes: 2 additions & 2 deletions data/mods/Megafauna/mf_weakpoint_sets.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"difficulty": { "all": 2 },
"coverage_mult": { "ranged": 0.3 },
"coverage": 10,
"required_effects": [ "downed" ],
"condition": { "npc_has_any_effect": [ "downed" ] },
"effects": [
{
"effect": "stunned",
Expand Down Expand Up @@ -79,7 +79,7 @@
"difficulty": { "melee": 2, "ranged": 4 },
"coverage_mult": { "ranged": 0.5 },
"coverage": 25,
"required_effects": [ "downed" ],
"condition": { "npc_has_any_effect": [ "downed" ] },
"effects": [
{
"effect": "nausea",
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Xedra_Evolved/weakpoints/wp_alien_being.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"damage_required": [ 31, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Xedra_Evolved/weakpoints/wp_combat_cyborg.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"damage_required": [ 31, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down
6 changes: 3 additions & 3 deletions data/mods/classic_zombies/monsters/weakpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"damage_required": [ 4, 100 ]
}
],
"required_effects": [ "grabbing" ],
"condition": { "npc_has_any_effect": [ "grabbing" ] },
"coverage": 8
},
{
Expand Down Expand Up @@ -164,7 +164,7 @@
"damage_required": [ 51, 100 ]
}
],
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
}
]
},
Expand Down Expand Up @@ -513,7 +513,7 @@
"damage_required": [ 51, 100 ]
}
],
"required_effects": [ "downed" ]
"condition": { "npc_has_any_effect": [ "downed" ] }
}
]
},
Expand Down
5 changes: 3 additions & 2 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ For example, `{ "npc_has_effect": "Shadow_Reveal" }`, used by shadow lieutenant,
| mutation: "deactivated_eocs" | character (Character) | NONE |
| mutation: "processed_eocs" | character (Character) | NONE |
| recipe: "result_eocs" | crafter (Character) | NONE |
| monster death: "death_function" | killer (Creature, if exists, otherwise NONE)| victim (Creature) | Note that if monster was killed without a killer (falling anvil, explosion of a bomb etc), EoC would be built without alpha talker, so using EoC referencing `u_` would result in error. Use `has_alpha` condition before manipulating with alpha talker
| ammo_effect: "eoc" | shooter (Creature) | victim (if exist, otherwise NONE) (Creature) | `proj_damage`, int, amount of damage projectile dealt. Detonation via SPECIAL_COOKOFF ammo effect return `proj_damage` as 1. Note that if projectile miss the target, EoC would be built without beta talker, so using EoC referencing `npc_` or `n_` would result in error. Use `has_beta` condition before manipulating with npc
| monster weakpoint: "effect_on_conditions" | attacker (Creature, if exists, otherwise NONE) | victim (Creature) | note that if weakpoint was hit without attacker, EoC would be built without alpha talker, so using EoC referencing `u_` would result in error. Use `has_alpha` condition before manipulating alpha talker
| monster death: "death_function" | killer (Creature, if exists, otherwise NONE)| victim (Creature) | Note that if monster was killed without a killer (falling anvil, explosion of a bomb etc), EoC would be built without alpha talker, so using EoC referencing `u_` would result in error. Use `has_alpha` condition before manipulating alpha talker
| ammo_effect: "eoc" | shooter (Creature) | victim (if exist, otherwise NONE) (Creature) | `proj_damage`, int, amount of damage projectile dealt. Detonation via SPECIAL_COOKOFF ammo effect return `proj_damage` as 1. Note that if projectile miss the target, EoC would be built without beta talker, so using EoC referencing `npc_` or `n_` would result in error. Use `has_beta` condition before manipulating npc

Some actions sent additional context variables, that can be used in EoC, in format:

Expand Down
4 changes: 2 additions & 2 deletions doc/MONSTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ Field | Description
`armor_penalty` | object mapping damage types to flat penalties on the monster's protection, applied after the multiplier.
`damage_mult` | object mapping damage types to multipliers on the post-armor damage, when hitting the weakpoint.
`crit_mult` | object mapping damage types to multipliers on the post-armor damage, when critically hitting the weakpoint. Defaults to `damage_mult`, if not specified.
`required_effects` | list of effect names applied to the monster required to hit the weakpoint.
`disabled_by` | list of effect names applied to the monster which prevent you to hit the weakpoint.
`condition` | condition, that need to be met for weakpoint to be used. `u_` is attacker (if presented, use `has_alpha` condition for safety), `npc_` is victim. See EFFECT_ON_CONDITION.md for more information
`effects` | list of effects objects that may be applied to the monster by hitting the weakpoint.

The `effects` field is a list of objects with the following subfields:

Field | Description
--- | ---
`effect` | The effect type.
`effect_on_conditions` | Array of EoCs that would be run. `u_` is attacker (if presented, use `has_alpha` condition for safety), `npc_` is victim. See EFFECT_ON_CONDITION.md for more information
`chance` | The probability of causing the effect.
`duration` | The duration of the effect. Either a (min, max) pair or a single value.
`permanent` | Whether the effect is permanent.
Expand Down
4 changes: 3 additions & 1 deletion src/dialogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <vector>

#include "cata_lazy.h"
#include "dialogue_helpers.h"
#include "dialogue_win.h"
#include "global_vars.h"
#include "npc.h"
#include "npc_opinion.h"
#include "talker.h"
#include "translations.h"
#include "type_id.h"
Expand All @@ -23,6 +24,7 @@ class JsonArray;
class JsonObject;
class martialart;
class mission;
class npc;
struct dialogue;
struct input_event;

Expand Down
1 change: 1 addition & 0 deletions src/martialarts.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <utility>
#include <vector>

#include "bodypart.h"
#include "bonuses.h"
#include "effect_on_condition.h"
#include "calendar.h"
Expand Down
1 change: 1 addition & 0 deletions src/math_parser_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "math_parser_diag_value.h"
#include "mongroup.h"
#include "mtype.h"
#include "npc.h"
#include "options.h"
#include "string_input_popup.h"
#include "units.h"
Expand Down
1 change: 1 addition & 0 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "localized_comparator.h"
#include "make_static.h"
#include "memory_fast.h"
#include "npc.h"
#include "string_formatter.h"
#include "trait_group.h"
#include "translations.h"
Expand Down
38 changes: 1 addition & 37 deletions src/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "memory_fast.h"
#include "mission_companion.h"
#include "npc_attack.h"
#include "npc_opinion.h"
#include "pimpl.h"
#include "point.h"
#include "sounds.h"
Expand Down Expand Up @@ -229,43 +230,6 @@ struct npc_personality {
void deserialize( const JsonObject &data );
};

struct npc_opinion {
int trust;
int fear;
int value;
int anger;
int owed; // Positive when the npc owes the player. Negative if player owes them.
int sold; // Total value of goods sold/donated by player to the npc. Cannot be negative.

npc_opinion() {
trust = 0;
fear = 0;
value = 0;
anger = 0;
owed = 0;
sold = 0;
}

npc_opinion &operator+=( const npc_opinion &rhs ) {
trust += rhs.trust;
fear += rhs.fear;
value += rhs.value;
anger += rhs.anger;
owed += rhs.owed;
sold += rhs.sold;
return *this;
}

npc_opinion operator+( const npc_opinion &rhs ) {
return npc_opinion( *this ) += rhs;
}

void serialize( JsonOut &json ) const;
void deserialize( const JsonObject &data );
};



enum class combat_engagement : int {
NONE = 0,
CLOSE,
Expand Down
1 change: 1 addition & 0 deletions src/npc_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "itype.h"
#include "json.h"
#include "mutation.h"
#include "npc.h"
#include "rng.h"
#include "skill.h"
#include "trait_group.h"
Expand Down
Loading

0 comments on commit 4a935ad

Please sign in to comment.