Is there a way to access/broadcast the range of an ability on selection?
I am working on a real time point click game. The goal goal would be displaying the range of an ability after it has been selected using a decal that follows the mouse until the ability has been activated.
  • Not out of the box, but you can access the shortcut of the ability (or item) via scripting during target selection and it being performed as the combatant's active shortcut:
    combatant.Shortcuts.Active
    combatant is an instance of the Combatant and this returns an IShortcut implementation (e.g. an AbilityShortcut or ItemShortcut).
    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!
  • I am writing a component for the player, how do I know when the target selection is being performed on a component?
  • edited November 2022
    You can check that via the current mode of the battle menu:
    if(BattleMenuMode.Target == combatant.Battle.BattleMenu.Mode)

    The battle menu is only initialized for player combatants, so if used for other combatants, do a null check for it first (combatant.Battle.BattleMenu != null).
    Post edited by gamingislove on
    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!
  • This is what I was planning to do:

    public Combatant combatant;
    private IShortcut abilityShortcut;

    void Start()
    {
    combatant = ORKComponentHelper.GetCombatant(this.gameObject);
    }

    void Update()
    {
    if(BattleMenuMode.Target == combatant.Battle.BattleMenu.Mode)
    {
    abilityShortcut = combatant.Shortcuts.Active;
    // Use abilityShortcut functions
    }
    }


    Unfortunately none of the abilityShortcut interface functions I can see, seems to point toward the ability range, am I doing something wrong?
  • edited November 2022
    You can access them via the ability's settings, all of that is part of the target settings ... easiest way is like this:
    TargetSettings settings = TargetSettings.Get(abilityShortcut);
    The target settings have all range settings and functions to access them.
    Post edited by gamingislove on
    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!
  • That's working, thank you!
    Is there a way to know when the shortcut ability has been used? I tried this but it looks like the range value remains the same even after the ability has been activated..

    void Update()
    {
    if(BattleMenuMode.Target == combatant.Battle.BattleMenu.Mode)
    {
    abilityShortcut = combatant.Shortcuts.Active;
    if(abilityShortcut!=null)
    {
    settings = TargetSettings.Get(abilityShortcut);
    range = settings.useRange.range.range[0].GetRangeValue(combatant);
    }
    else
    range = 0;
    }
    }

  • Naturally, the range value is independent of the ability being used or not.
    Though, you just need to add an else case for the battle menu mode check and reset the range here - i.e. reset the range field of your class when the battle menu is not in target mode.
    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!
  • Thank you Nicholas, that worked perfectly!
Sign In or Register to comment.