@gamingislove

Hello.
I recently played SoulStone Survivals game.

In that game ability can be executed during another ability.
For example player is casting beam and several aoe abilities can be also executed during that cast (actually any number of abilities can be cast simultaniusly).

I try to execute abilities by input keys. But I cant execute another ability while I am already performing one.
(disabling block player control in the schematic settings does not help).

How can I tell ork to execute ability during another ability?
  • So far the only way I have found is using sub actions.

    Test code for testing using ability during another ability.

    private async void Start()
    {
    var combatantComponent = GetComponent<CombatantComponent>();
    if (!combatantComponent) return;

    var combatant = combatantComponent.Combatant;

    var ability = combatant.Abilities.GetAll()[2];
    var action = BaseAction.CreateAbility(combatant, ability, 1, false, false);
    var ability2 = combatant.Abilities.GetAll()[4];
    var action2 = BaseAction.CreateAbility(combatant, ability2, 1, false, false);
    var action3 = BaseAction.CreateAbility(combatant, ability, 1, false, false);

    ORK.Access.Action.AddActionToCombatant(combatant, action, false);

    var currentAction = combatant.Actions.Current;

    await Task.Delay(250);
    if (currentAction != null) currentAction.AddSubAction(action2, true, true);

    await Task.Delay(250);
    if (currentAction != null) currentAction.AddSubAction(action3, true, true);

    await Task.Delay(2000);

    Start();
    }


    So to be able to use ability at any time (even if another action is processing)

    We need:
    If combatant has current action add ability as subaction of currentAction to combatant.
    If no current action just add ability as action to combotant.

    @gamingislove
    Is this a normal way? (Is there another ways?)

    Any chances to have such functional as build-in (without costume code)?

  • Currently a combatant can only perform one action at a time. Sub actions (e.g. via schematics using Use Battle Action node or code like yours) can be used to perform actions as part of another action - i.e. it'll not have an impact on the battle order and can also be used to perform another action at the same time.

    Future updates might allow multiple actions to be used at the same time. I have something like that on my todo-list, but can't say when and if that'll come (e.g. might break the system too much).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks.

    Being able to perform several different actions(abilities) would be grate.
    There is a plenty of situations there it could be used.

    Soldger is firing from autogun, and kick with the leg at the same time without stopping firing.
    Some bull is performing rush in stright line and fires some projectiles perpendicularly of movemtnt simultaniously.
    And so on.

    This feature is worse investigating.

    I hope this will be added someday.

    For now I will try to use SubActions.

    Also I Found another related thread, there the solution for that problem is the same.
    https://forum.orkframework.com/discussion/7235/moving-with-use-battle-action-node#latest
  • @gamingislove


    private void Update()
    {
    if (combatant == null) return;

    if (Input.GetKeyDown(KeyCode.F)) CastAbility("RangedAttack");
    if (Input.GetKeyDown(KeyCode.G)) CastAbility("RangedAttack2");

    void CastAbility(string ability)
    {
    var abilityShortcut = combatant.Abilities.Get(ORK.Abilities.Get(ability));
    if (!abilityShortcut.CanUse(combatant, true, true)) return;

    var abilityAction = BaseAction.CreateAbility(combatant, abilityShortcut, 1, true, true);
    if (abilityAction == null) return;
    if (!abilityAction.CanUse()) return;
    if (combatant.Actions.IsCastingShortcut(abilityShortcut)) return;
    if (combatant.Actions.GetCastingAction() != null && combatant.Actions.GetCastingAction().Shortcut == abilityShortcut) return;
    if (combatant.Actions.GetNextAction() != null && combatant.Actions.GetNextAction().Shortcut == abilityShortcut) return;

    var currentAction = combatant.Actions.Current;
    if (currentAction == null)
    combatant.Actions.Add(abilityAction, false);
    else
    {
    if (currentAction.Shortcut == abilityShortcut) return;
    currentAction.AddSubAction(abilityAction, false, false);
    }
    }
    }


    I am trying to adapt subactions.
    They kind of working. I can use one ability during another at any time.

    If I press same button G G G G - ability will be executed only by CD (correct begaviour)

    But I cant find the way to not use same ability if it was cast and subAction was added.
    I can press G, F, G, F, G, F infinetly and all abilities will be fired with no cd. (incorrect behavior).

    @gamingislove
    How to tell if ability is currently executed or "overriden" by subaction?

  • TextusGames said: How to tell if ability is currently executed or "overriden" by subaction?
    Well, you can't really ...
    You'd need to do this manually, e.g. using object variables on the user. Each action could set a string variable (or some other variable) to identify which action is currently used (and reset/remove that variable at the end). Checking the variable would determine which action is used.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • @gamingislove

    Ok.

    Another question.
    Can I manually handle ability execution (ignoring Combatan.Actions, not adding ability there)) .
    I mean write ability logic somethere else (in code for example) and use ability for storing data for adding removing from combatant for UI and so on.
    But execute it mannually (.
    Like this:


    [SerializeField] private AnimationTypeAsset rangedAttackAnimationType;
    [SerializeField] private GameObject projectileSample;

    private void Update()
    {
    if (combatant == null) return;
    if (Input.GetKeyDown(KeyCode.E)) RangedAttackAbility();
    }

    private async void RangedAttackAbility()
    {
    var abilityShortcut = combatant.Abilities.Get(ORK.Abilities.Get("RangedAttack"));
    if (!abilityShortcut.CanUse(combatant, true, true)) return;

    var abilityAction = new AbilityAction(combatant, abilityShortcut);
    //await RotateToTarget();

    combatant.Animations.Play(rangedAttackAnimationType);
    await Task.Delay(600);

    abilityAction.ConsumeCosts();
    abilityShortcut.FireUseCountChanged();
    var instance = Instantiate(projectileSample, transform.position + new Vector3(0, 1, 1), Quaternion.LookRotation(transform.forward));
    var instanceDamageDealer = instance.GetComponent<DamageDealer>();
    instanceDamageDealer.SetAction(abilityAction);
    instanceDamageDealer.SetDamageActive(true);
    await Task.Delay(100);
    }


    This code is kind of projectile cast ability and it works.
    Is this approach valid?

    Is anything wrong with creating AbilityAction from ability shortcat and not adding it to CombatantActions but just setting it to damageDealer or even mannually call performAction at a right time?
  • Well, if it works, it works :)
    As long as the action isn't registered with the system and performed, it'll not impact the battle order.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.