An ability to specify attack type in controls.use value

Related to !4102 (merged) Allows more granular control over attack types (swing directions) via Lua api's ´self.controls.use´. Values 0 - 3 are accepted, 0 is still "no attack", while the rest are:

std::string_view attackTypeName(int attackTypeNum)
{
    if (attackTypeNum == 1)
        return "chop";
    else if (attackTypeNum == 2)
        return "slash";
    else if (attackTypeNum == 3)
        return "thrust";
    else
        return "";
}

Values above 0 will result in a specific attack type used only on disabled AI actors. On non-disabled triggering use with any value above 0 will result in a regular AI attack behaviour. Probably a check for CreatureStats:getAttackType() can be extended to enabled AIs as well, with a swing direction being overridden only when getAttackType is not "". But I'm not entirely sure how to do that properly.

Also it's not exactly clear to me how CreatureStats works and if the CreatureStats.mAttackType that I've added will persist once set, or will be cleared every frame similarly to controls.use, the latter would be preferable.

And on another note - if this goes - both CreatureStats and CharacterController will have mAttackType property, and they will not necessarily contain the same value. As the intent goes, mAttackType on CretureStats is more of a "desired" attack type, rather than one that will be used, e.g setting "slash" mAttackType on CreatureStats will not change a "shoot" mAttackType type on a CharacterController wielding a bow. So maybe it's worth remaining CreaureStats.mAttackType to mDesiredAttackType for extra clarity? Or even mScriptedAttackType?

Based on @ptmikheev 's suggestion.

Edited by MaxYari

Merge request reports

Loading