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

Allow limbs to define MA techniques and unarmed damage, expand MA tech functionality #53939

Merged
merged 8 commits into from
Jan 6, 2022

Conversation

Venera3
Copy link
Member

@Venera3 Venera3 commented Jan 1, 2022

Summary

Infrastructure "Enhance martial art techniques, allow limbs to define technique lists and unarmed damage boni"

Purpose of change

Infrastructure changes in preparation for reworking mutation special attacks as part of the limb project. Lays the groundwork to move them over from freebie procs to MA techniques and adds some functionality to techs to allow for moving as much mutation functionality over as possible.

Describe the solution

  • Added techniques and technique_encumbrance_limit (list and bool) to bodypart definitions. On querying the applicable melee techniques the part will return them as long as a current encumbrance in encumbrance tech limit roll fails
  • Added tech_effects to allow for a freely defined list of effects to apply on a successful trigger - by default only if the technique does damage, but that's overrideable with on_damage: false
  • Added the ability to filter applicable techs by character flags (bionic, effect, trait, or bodypart flags) - either requiring any flag from the req_character_flags or being disabled on any of the forbidden_char_flags
  • Added attack_override to simulate the melee tech replacing as much of the original attack as it's possible without rewriting the whole melee attack function (see alternatives) - it zeroes both its damage and movement cost and turns the attack unarmed for the purposes of melee special effects and skill training, instead using the tech's flat_bonuses
  • Unlocked all damage types for melee attack techs
  • Added unarmed_damage to limb definitions, allowing the bodypart to define damage and armor penetration bonuses for every damage type. Currently the bonuses of all limbs stack, that should be easy enough to limit to the chosen attack vector when that system is in place.

TODO:

  • Barring any objections move the stunning/downing MA techs over to the tech_effects array and deprecating that code The tech picking function incudes some checks to prevent you choosing a stunning tech on an already stunned enemy, so this would result in tech picking becoming a bit dumber. I'll just include the effect array in the demo tech
  • Maybe add a chance to use to techs to prevent you from using only your mutant bits - It turns out a negative weighting already achieves this, more or less. Yay for undocumented features, I guess.
  • Try adding unarmed damage boosts to limbs, but my track record isn't great with damage.cpp Shamelessly repurposing dseguin's armor code was easier than I expected. Bodyparts can now contribute to unarmed damage and armor penetration (per damage type), using any damage type provided they are either uncovered or are wearing armor with ALLOW_NATURAL_ATTACKS - it could stand to be a bit more gradual, but it works for now. I might look into arbitrary flag definitions (yoinked from mutations' allowed_items, of course), but it works for a first pass
  • Add a demonstration tech/damage to Debug Tail

Describe alternatives you've considered

attack_override is clumsily special-cased here and there in the melee attack abstract code. The reason for that is that techniques only get chosen after a hit is rolled based on the weapon and crit, so the attack will still use the base weapons' to-hit and stamina cost in effect. The alternative would be to reorganize the whole function and decide on the attempted technique before the hit rolls(overriding the attack setting force_unarmed), which could then fail if e.g. an attempt at a crit tech failed to roll a crit in reality. I think that system would make more sense than waiting to hit and deciding "hey I was actually doing my super crit attack, no backsies!", but I also don't want to be the one doing that rewrite.

If attack_override is seen as an insufficient solution I would need to turn mutant limb attacks into unarmed-only techs, which is workable but not ideal (you should take a bite out of your enemies occasionally if you have raptor fangs and are in melee, in my head).

I hope turning on the other damage types for all melee attacks is acceptable, the alternative would be either checking if the tech downstream has any acid etc. components and only passing the type then or adding the damage type back in perform_technique, both of which are considerably more involved than removing a =.

Gating any one from the effect list behind set character flags, but adding two/three separate techs to unhardcode venomous attacks seems like an acceptable amount of duplication.

Testing

Limbs add their melee techs to the tech list.
The techs use the requirements (including flags) as defined.
Effects are applied in the desired duration, chance and damage relation.
Added nonstandard damage types are applied on successful tech hits.
Attack_override replaces the base characteristics of the attack.
Unarmed damage and armor penetration is applied from limbs.

Additional context

@Hymore246 this might be of interest.

The tech effect code is the same system monster special attacks use with the serial numbers filed off and some fields removed. I tried using the newer JSON readers but I could not get it to work, and it does the job well enough.

All damage types, mult before flat, encumbrance-based chances
Ondamage, duration, chance etc work
@github-actions github-actions bot added the json-styled JSON lint passed, label assigned by github actions label Jan 1, 2022
@Shodan14
Copy link

Shodan14 commented Jan 1, 2022

Tentacle kung fu here we come!

@Maleclypse Maleclypse added Mechanics: Character / Player Character / Player mechanics Melee Melee weapons, tactics, techniques, reach attack labels Jan 1, 2022
@Hymore246
Copy link
Contributor

Hymore246 commented Jan 1, 2022

Yeah, working on something similar to this right now. I called it "attack vectors" where you define which body parts can be used by a technique. A Jab uses HAND and Roundhouse Kick uses FOOT and so on. This will be combined with an expansion of #41209 which will allow clothing to contribute to damage. I am still developing the code for this and it will require me to add attack vectors to every technique in the game. In addition, I will also need to update to "roll damage" formulas. So, this is a pretty extensive update that needs a lot of testing.

EDIT: My draft for attack vectors #53954

@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 2, 2022
@Venera3 Venera3 changed the title Allow limbs to define MA techniques, expand MA tech functionality Allow limbs to define MA techniques and unarmed damage, expand MA tech functionality Jan 3, 2022
@Venera3
Copy link
Member Author

Venera3 commented Jan 3, 2022

Well I have ever so slightly accidentally broke it once, but this should be ready for review now. In case passing all damage types back from roll_other_damage is considered wasteful, I can reinstate the check and effectively require that techs using nonstandard damage types have at least one source of damage from that type, but since traits are limited to the physical ones that would get messy. I might look into adding all damage types for mutations, but it would be a tangent.

@Venera3 Venera3 marked this pull request as ready for review January 3, 2022 20:19
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 4, 2022
@@ -2135,7 +2209,7 @@ std::string Character::melee_special_effects( Creature &t, damage_instance &d, i
std::string target = t.disp_name();

if( has_active_bionic( bio_shock ) && get_power_level() >= bio_shock->power_trigger &&
( !is_armed() || weapon.conductive() ) ) {
( weap.is_null() || weapon.conductive() ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't weap and weapon the same in the end?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I misread weapon refers back to the character's wielded weapon, whereas weap is the argument passed to this function. attack_overwrite techs instead pass null as their weap.

I tried setting cur_weapon to null before which would have been much cleaner but it made the player's weapon disappear on a trigger.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When melee_special_effects is called from melee_attack_abstract, weap parameter is cur_weapon.

Then item *cur_weapon = allow_unarmed ? &used_weapon() : &weapon; and used_weapon is defined as martial_arts_data->selected_force_unarmed() ? null_item_reference() : weapon;

Basically if unarmed attack is allowed, currently wielded weapon (weapon) will bed used unless martial art forces an unarmed attack.

What bothers me is melee_special_effects using both weap and weapon in some checks. Say, you attack w/o weapon (because martial art forces you) and weap is null_item_reference, but you will still get zapped in case your weapon is conductive and you will add fire damage if wielded weapon has FLAMING flag.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the current sequence of the attack is weird like that. Ideally I'd imagine changing the sequence so that the attempted technique gets decided first setting the used weapon (forced unarmed/attack override or your wielded weapon), it uses that weapons' to-hit for the hit roll, then checking if the technique you were attempting succeeded (and applying the message/special effects/monster defense depending on what weapon you used). However, while that would make more sense it would also pretty much completely invalidate the current martial arts' sequencing of techniques and general balance - that isn't something I feel comfortable doing, especially not without having more of a plan for MAs than "it'll be neater under the hood".

@kevingranade kevingranade merged commit d6fcc5b into CleverRaven:master Jan 6, 2022
@catdach catdach mentioned this pull request Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions json-styled JSON lint passed, label assigned by github actions Mechanics: Character / Player Character / Player mechanics Melee Melee weapons, tactics, techniques, reach attack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants